#UseContext vs exported signals

1 messages · Page 1 of 1 (latest)

lime basalt
#

Hey hey :), there is a chapter on solid tutorial page regarding using context provider for sharing states. Its about a CounterProvider using create context for sharing the count state. In that case I could also simply move this signal creation into a single export file and consume the signal for get and set on any place. So why and whats the thing of using the context based flow?

#

UseContext vs exported signals

dry tulip
#

You may want to bind state to a parent in order to share it just between selected nodes (e.g. different tabs component instances).

lime basalt
#

Ok, I see, but for global state handling is it ok to go with a none UseContext flow?

dry tulip
#

Sure global state is encouraged in solid.

regal sandal
#

Context is also important in terms of SSR, to avoid having singletones shared across requests