Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 668ab80

Browse files
committed
better explain when and why to use context
1 parent b6f6080 commit 668ab80

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

langs/en/tutorials/stores_nocontext/lesson.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const [count, setCount] = counter;
1414

1515
Solid's reactivity is a universal concept. It doesn't matter if it is inside or outside components. There is no separate concept for global vs local state. It is all the same thing.
1616

17-
The only restriction is that all computations (Effects/Memos) need to be created under a reactive root (`createRoot`). Solid's `render` does this automatically.
17+
The only restriction is that all computations (Effects/Memos) need to be created under a reactive root (`createRoot`). Solid's `render` does this automatically. So when using your own more complicated global stores that contain computations, it's usually best to use Context.
1818

1919
In this tutorial `counter.tsx` is such a global store. We can use it by modifying our component in `main.tsx` to:
2020

@@ -28,4 +28,4 @@ return (
2828
);
2929
```
3030

31-
So when using your own more complicated global stores that contain computations, be sure to create a root. Or better yet, do yourself a favor and just use Context.
31+
> It is possible to create your own root to hold the global store, instead of using Context, but Context is generally a simpler solution. Additionally, it is important not to use global state if you are using an SSR (server side rendering) solution, such as Solid Start, because then the global state may be shared globally across sessions!

0 commit comments

Comments
 (0)