Replies: 2 comments 11 replies
-
|
|
Beta Was this translation helpful? Give feedback.
11 replies
-
|
An alternative would be to update getDefaultStore() to always throw in server environments. This would be a breaking change however. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The provider-less mode, with it's singleton default store, is a big footgun for server-rendered apps -- potentially allowing data to leak between requests (e.g. #1603).
I understand that the guidance for server-rendered apps is to just always use a
<Provider>, but this could be difficult to enforce at scale. In a large codebase, with many React applications and many developers, it's likely that someone will eventually forget to include the necessary provider somewhere.Would you be open to an API that allows users to override the behavior of
getDefaultStore?This would allow projects to easily disable the feature outright:
or they could replace the default store with one that is scoped to a single request. Implementation would be framework-specific, and outside the scope of Jotai, but a node web app could do something with AsyncLocalStorage -- roughly:
Beta Was this translation helpful? Give feedback.
All reactions