Skip to content

Using solid with typescript: Is this code snippet a bad practice? #412

Answered by ryansolid
samadadi asked this question in Q&A
Discussion options

You must be logged in to vote

This is fine.. Although there is some limits to what can live outside the render tree.. Computations like createEffect or createMemo 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…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@samadadi
Comment options

@samadadi
Comment options

@ryansolid
Comment options

Answer selected by ryansolid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants