We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02441c6 commit c1ef7d7Copy full SHA for c1ef7d7
.changeset/young-pillows-join.md
@@ -0,0 +1,5 @@
1
+---
2
+"svelte": patch
3
4
+
5
+chore: prevent usage of getContext during component template
packages/svelte/src/internal/client/runtime.js
@@ -949,7 +949,11 @@ export function getAllContexts() {
949
/** @returns {Map<unknown, unknown>} */
950
function get_or_init_context_map() {
951
const component_context = current_component_context;
952
- if (component_context === null) {
+ if (
953
+ component_context === null ||
954
+ current_effect === null ||
955
+ (current_effect.f & BRANCH_EFFECT) === 0
956
+ ) {
957
throw new Error(
958
'ERR_SVELTE_ORPHAN_CONTEXT' +
959
(DEV ? 'Context can only be used during component initialisation.' : '')
0 commit comments