From 92422fdee2b99761eda8a2b191e77953ad7334a0 Mon Sep 17 00:00:00 2001 From: Outvi V <19144373+outloudvi@users.noreply.github.com> Date: Sun, 27 Jun 2021 02:05:17 +0800 Subject: [PATCH] doc: Add notes to stress call-context-during-initialisation (#5631) --- site/content/tutorial/15-context/01-context-api/text.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/tutorial/15-context/01-context-api/text.md b/site/content/tutorial/15-context/01-context-api/text.md index 96a716dfb0..dc5f2d7e8b 100644 --- a/site/content/tutorial/15-context/01-context-api/text.md +++ b/site/content/tutorial/15-context/01-context-api/text.md @@ -19,7 +19,7 @@ setContext(key, { }); ``` -The context object can be anything you like. Like [lifecycle functions](tutorial/onmount), `setContext` and `getContext` must be called during component initialisation; since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself. +The context object can be anything you like. Like [lifecycle functions](tutorial/onmount), `setContext` and `getContext` must be called during component initialisation. Calling it afterwards - for example inside `onMount` - will throw an error. In this example, since `map` isn't created until the component has mounted, our context object contains a `getMap` function rather than `map` itself. On the other side of the equation, in `MapMarker.svelte`, we can now get a reference to the Mapbox instance: