-
Basically I am using solid context api and typescript to handle application state. Is this code a bad practice of using createState & createContext api or the whole code? If so please explain why? If you have any question about this code please ask me. Thanks.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is fine.. Although there is some limits to what can live outside the render tree.. Computations like To be fair the simplest state management with Solid is just creating a signal in a file and export it.. It's more or less Svelte's stores, but I find the context pattern a lot more extensible. This comment might be helpful: #300 (comment) |
Beta Was this translation helpful? Give feedback.
This is fine.. Although there is some limits to what can live outside the render tree.. Computations like
createEffect
orcreateMemo
won't work properly, so generally I don't recommend doing this if you have any desire to see this grow. Instead I recommend initializing your store inside the provider. Of course this makes typing a bit annoy since context in theory can fail to find so it is nullable. I do realize it is difficult for typing at create. I've debated even removing the default state since it has limited use, but then again you can use Context API with anything.To be fair the simplest state management with Solid is just creating a signal in a file and export it.. It's more or le…