Do I need a Provider? #384
-
Guys, I'm doing some examples which works even without a provider. So...
Atom configs don't hold values. Atom values are stored in a Provider. A Provider can be used like React context provider. Usually, we place one Provider at the root of the app, however you could use multiple Providers, each storing different atom values for its component tree.. What's the difference if I do not use a Provider? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hmm, yes and no, we introduced provider-less mode a time ago. If you have a SSR app that needs to provide initial values for atoms on the server-side render phase, yes, you have to use Provider with initialValue prop in it. But if not, you don't need to use the Provider anymore. Or, for better debugging and seeing all values, we use the provider.
Yes, why not? You can use more providers to provide different values for different subtrees.
|
Beta Was this translation helpful? Give feedback.
Hmm, yes and no, we introduced provider-less mode a time ago. If you have a SSR app that needs to provide initial values for atoms on the server-side render phase, yes, you have to use Provider with initialValue prop in it. But if not, you don't need to use the Provider anymore. Or, for better debugging and seeing all values, we use the provider.
Yes, why not? You can use more providers to provide different values for different subtrees.