Complete the code to set a context value in a Svelte component.
<script> import { setContext } from 'svelte'; const key = 'user'; const user = { name: 'Alice' }; setContext([1], user); </script>
You use the variable key as the context key when calling setContext.
Complete the code to get a context value in a Svelte component.
<script> import { getContext } from 'svelte'; const key = 'theme'; const theme = getContext([1]); </script>
You retrieve the context value using the variable key which holds the context key.
Fix the error in the code to correctly share context between components.
<script> import { setContext, getContext } from 'svelte'; const key = Symbol('settings'); setContext(key, { darkMode: true }); const settings = getContext([1]); </script>
The same key variable holding the Symbol must be used in both setContext and getContext.
Fill both blanks to create and use a unique context key with Symbol.
<script> import { setContext, getContext } from 'svelte'; const [1] = [2]('auth'); setContext(authKey, { loggedIn: false }); const auth = getContext(authKey); </script>
Use authKey as the variable name and Symbol to create a unique key.
Fill all three blanks to set and get context using a constant key string.
<script> import { setContext, getContext } from 'svelte'; const [1] = '[2]'; setContext([3], { language: 'en' }); const lang = getContext(langKey); </script>
Define langKey as the constant key variable, assign it the string language, and use langKey in setContext.