react-redux icon indicating copy to clipboard operation
react-redux copied to clipboard

Cannot compile react-native TS without react-dom in 8.x

Open slaci opened this issue 2 years ago • 5 comments

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React Native: 0.70.2
  • React Redux: 8.0.4

What is the current behavior?

On tsc compile I get the following error in a react-native project:

node_modules/react-redux/es/utils/reactBatchedUpdates.d.ts:1:41 - error TS2307: Cannot find module 'react-dom' or its corresponding type declarations.

1 export { unstable_batchedUpdates } from 'react-dom';

Previous version (7.2.9) compiles without any error.

What is the expected behavior?

The react-dom package should not be required for a react-native project.

Which browser and OS are affected by this issue?

No response

Did this work in previous versions of React Redux?

  • [X] Yes

slaci avatar Oct 07 '22 13:10 slaci

Even though react-dom is not required on runtime if you are in a react-native environment, the types are referencing it - you should be fine by just having @types/react-dom installed in your project.

phryneas avatar Oct 07 '22 13:10 phryneas

I'm totally fine with that, but didn't know that would fix this error. I tried it and now it's all good so I'm closing. Thanks for the info!

slaci avatar Oct 07 '22 13:10 slaci

Hmm. Interesting. There may be something we can tweak here to fix that, actually.

markerikson avatar Oct 07 '22 14:10 markerikson

I wish one-month-ago me had written down what he was thinking, because current-me has no idea what that was :)

markerikson avatar Nov 04 '22 02:11 markerikson

Sadly I'm not familiar enought with typescript to be able to help you with this, but at least I can confirm again that installing @types/react-dom workarounds the issue.

slaci avatar Nov 04 '22 08:11 slaci

Old and no further discussions, so I'm going to close this.

markerikson avatar May 02 '24 00:05 markerikson