react-redux
react-redux copied to clipboard
Cannot compile react-native TS without react-dom in 8.x
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
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.
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!
Hmm. Interesting. There may be something we can tweak here to fix that, actually.
I wish one-month-ago me had written down what he was thinking, because current-me has no idea what that was :)
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.
Old and no further discussions, so I'm going to close this.