Skip to content
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

can't use react-redux with ink #1457

Closed
mprast opened this issue Nov 11, 2019 · 4 comments
Closed

can't use react-redux with ink #1457

mprast opened this issue Nov 11, 2019 · 4 comments

Comments

@mprast
Copy link

mprast commented Nov 11, 2019

Do you want to request a feature or report a bug?
report a bug
(If this is a usage question, please do not post it here—post it on Stack Overflow instead. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

What is the current behavior?
I'm trying to use react-redux with ink and yarn v2. When I attempt to import Provider I'm met with the following:


Error: A package is trying to access another package without the second one being listed as a dependency of the first one

Required package: react-dom (via "react-dom")
Required by: react-redux@virtual:3acb2abc1dfd4a22564c3a11c8c371d7f85acb8e75efb297111ee893174e7ed007fb72514c7f7294775b8562215f979c751a99c9108a7c4c8e007fc4f67cd244#npm:7.1.3 (via /src/atlas/.yarn/virtual/react-redux-virtual-638efc0d6c/3/root/.yarn/berry/cache/react-redux-npm-7.1.3-f0c157eca3.zip/node_modules/react-redux/lib/utils/reactBatchedUpdates.js)

    at Object.makeError (/src/atlas/.pnp.js:13858:26)
    at resolveToUnqualified (/src/atlas/.pnp.js:16265:43)
    at resolveRequest (/src/atlas/.pnp.js:16311:31)
    at Object.resolveRequest.maybeLog [as resolveRequest] (/src/atlas/.pnp.js:16350:32)
    at Function.module_1.default._resolveFilename (/src/atlas/.pnp.js:15781:37)
    at Function.module_1.default._load (/src/atlas/.pnp.js:15702:45)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/src/atlas/.yarn/virtual/react-redux-virtual-638efc0d6c/3/root/.yarn/berry/cache/react-redux-npm-7.1.3-f0c157eca3.zip/node_modules/react-redux/lib/utils/reactBatchedUpdates.js:6:17)
    at Module._compile (internal/modules/cjs/loader.js:776:30)

I'm guessing it's because react-redux is trying to do a static import here:

import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:

demo: https://codesandbox.io/s/festive-leftpad-cjr2w

What is the expected behavior?
I'm expecting to be able to use Redux without react-dom or react-native, since the impression I got from the docs is that react-redux doesn't or shouldn't have hard dependencies on a particular rendering library (if I'm mistaken and didn't miss something obvious it might be a good idea to add a disclaimer to the README!)

For now I can add react-dom as an easy workaround, but it'd be nice not to have the extra dependency just so I can import Provider and connect

Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
React: 16.11.0
ReactDOM/React Native: N/A
ink: 2.5.0
Redux: 4.0.4
React Redux: 7.1.3

@markerikson
Copy link
Contributor

We do have a sort-of hard dependency on either react-dom or react-native, due to our need to use the unstable_batchedUpdates API they both export.

For other renderers, you'll need to use the "react-redux/alternate-renderers" entry point. It looks like we don't have that formally listed in the documentation atm, but you can see a description in the v7 release notes:

https://github.com/reduxjs/react-redux/releases/tag/v7.0.1

@timdorr
Copy link
Member

timdorr commented Nov 11, 2019

Closing to track in #1458

@timdorr timdorr closed this as completed Nov 11, 2019
@mprast
Copy link
Author

mprast commented Nov 12, 2019

oh, 'alternate-renderers' looks like what I needed. Thank you!

@markerikson
Copy link
Contributor

@mprast sure! Please let us know if you have any issues using that - I'm not sure how many people have actually used it for real :) But, yeah, that's exactly why we added it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants