Svelte · Junior · Question 42 of 76
When must setContext / getContext be called?
- ✓Correct answer: During component initialization, at the top level of
<script>, not in event handlers or afterawait - 2Anywhere, at any time
- 3Only inside
onMount
Explanation
Context is tied to the component being created. Since Svelte 5.40, createContext gives a typed [get, set] pair.