-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSC-specific workarounds #2050
RSC-specific workarounds #2050
Conversation
* use `{}` as ReactReduxContext in environments where no context exists * switch React imports to namespace imports to prevent hook import detection
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9a02b4c:
|
Is that import switch going to cause any kind of bundle size issue? (Although... I guess React doesn't get tree shaken anyway...) |
Pretty much this. All it does is slightly increase the size of the cjs build because it now has to add a namespace import helper function, but no bigger bundle size changes beyond that. |
} | ||
|
||
function getContext(): Context<ReactReduxContextValue> { | ||
if (!React.createContext) return {} as any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an environment where createContext
does not exist we can pretty much just return anything - there is no useContext
that could consume it anyways - and this avoids a hard error being thrown futher down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the provider needs to be in a client component, so presumably that won't be an issue either
I just cherrypicked this commit b37e57e in here since I had forgotten to merge that over earlier. @EskiMojo14 could you take another look please? |
yep, still lgtm |
{}
as ReactReduxContext in environments where no context exists