Document that context is not reactive. (#3296)

pull/3297/head
pngwn 6 years ago committed by Conduitry
parent e82d5d44c1
commit fcfad5ae6b

@ -156,6 +156,8 @@ Like lifecycle functions, this must be called during component initialisation.
</script>
```
> Context is not inherently reactive. If you need reactive values in context then you can pass a store into context, which *will* be reactive.
#### `getContext`
```js

@ -45,3 +45,5 @@ const key = {};
```
We can use anything as a key — we could do `setContext('mapbox', ...)` for example. The downside of using a string is that different component libraries might accidentally use the same one; using an object literal means the keys are guaranteed not to conflict in any circumstance, even when you have multiple different contexts operating across many component layers.
> Remember that context is not inherently reactive. If you need context values to be reactive then you can pass a store into context, which *will* be reactive.

Loading…
Cancel
Save