Closed stephane-vanraes closed 4 years ago
Using getContext
or any of the other lifecycle hook anywhere but during component initialization (i.e., synchronously from top-level code in the script block) is not supported, and it's currently a bug that calling it from within onMount doesn't immediately throw - see #4259.
Describe the bug When combining slots with the context API and a specific combination of
onMount
andsetTimeout
it appears as if two instances of the same component only share 1 context.Please refer to the REPL(s) for a demo with different combinations
Logs No logs except for 1 combo which gives
getContext(...) is not a function
To Reproduce https://svelte.dev/repl/439be129b8cd4070835a8b9121e18aae?version=3.20.1 https://svelte.dev/repl/167fa53e87ef425589037ba77cf5c28d?version=3.20.1
Expected behavior The child component calls the correct contextAPI