You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realise contexts are basically undocumented and unsupported so this is shaky territory API wise.
I have a use-case for multiple node packages with their own React installed. Each package provides a Component or two using its own React instance, from its own node_modules folder. I'm finding when using contexts I get the message:
Warning: owner-based and parent-based contexts differ (values:undefinedvsbar) for key (message) while mounting Message (see: http://fb.me/react-context-by-parent)
When I try and pass contexts down to all the elements.
If I consolidate the Components into one package then everything works as expected. If I keep separate packages, but export a factory that takes the React instance as a function, everything works as expected. Browserify probably conveniently gets around this with the dedupe if they're all identical versions. Running on the server unfortunately does not.
Running multiple instances of React is not currently supported. It's possible to work around that with some tweaks, but they still have to be isolated from each other, so you cannot use the instances interchangeably.
This is especially an issue with npm link with packages that also depend on React. It seems like ReactContext should go away when React switches to parent context instead of owner. Is that the case and will it fix this issue specifically?
I realise contexts are basically undocumented and unsupported so this is shaky territory API wise.
I have a use-case for multiple node packages with their own React installed. Each package provides a Component or two using its own React instance, from its own node_modules folder. I'm finding when using contexts I get the message:
Warning: owner-based and parent-based contexts differ (values:
undefinedvs
bar) for key (message) while mounting Message (see: http://fb.me/react-context-by-parent)
When I try and pass contexts down to all the elements.
If I consolidate the Components into one package then everything works as expected. If I keep separate packages, but export a factory that takes the React instance as a function, everything works as expected. Browserify probably conveniently gets around this with the dedupe if they're all identical versions. Running on the server unfortunately does not.
Here's a code sample with everything in 1 package working fine. You'll need to run npm install from the project root directory and run
node index.js
.Here's a code sample with the separate package and its own instance of React. You'll need to npm install from the project root directory and /node_modules/sub-component.
I have three questions:
Alternatively, am I using contexts incorrectly?
Thanks for your time, and a wonderful library.
The text was updated successfully, but these errors were encountered: