找不到模块' react-dom'来自' ../../ node_modules/@reduxjs/toolkit/node_modules/react-react-react-readux/lib/utils/reactbatchbatchedupdates.js'
我使用Redux工具包查询获取数据。 我在我的react-native应用程序中有以下导入:
import {createapi}来自'@reduxjs/toolkit/queery/react/react';
该应用程序效果很好,并且数据效果很好,但是测试是失败以下错误:
无法从'../../ node_modules/@reduxjs/toolkit/node_modules/react-react-react-reabreib/lib/utils/reactbatchedupdates.js'
''
但是,当我从以下内容导入时:
import {createapi}从'@reduxjs/toolkit/query';
>
一切都很好。
相关的软件包版本是:
"@reduxjs/toolkit": "^1.6.1",
"@types/jest": "^26.0.23",
"@types/jest-when": "^2.7.2",
"@types/react": "^17.0.39",
"@types/react-redux": "^7.1.16",
"babel-jest": "^26.6.3",
"jest": "^27.0.5",
"jest-junit": "^12.2.0",
"jest-when": "^3.2.0",
"react": "17.0.2",
"react-redux": "8.0.2",
这是Lerna MonorePo设置中的共享软件包。 有谁知道这里可能是什么问题,什么可能导致这个问题?
I use redux toolkit query to fetch the data.
I have the following import in my React-Native application:
import {createApi} from '@reduxjs/toolkit/query/react';
The application works fine, and data is fetching well, but the tests are failing with the following error:
Cannot find module 'react-dom' from '../../node_modules/@reduxjs/toolkit/node_modules/react-redux/lib/utils/reactBatchedUpdates.js'
But when I import from the following:
import {createApi} from '@reduxjs/toolkit/query';
everything works fine for the tests.
The relevant package versions are:
"@reduxjs/toolkit": "^1.6.1",
"@types/jest": "^26.0.23",
"@types/jest-when": "^2.7.2",
"@types/react": "^17.0.39",
"@types/react-redux": "^7.1.16",
"babel-jest": "^26.6.3",
"jest": "^27.0.5",
"jest-junit": "^12.2.0",
"jest-when": "^3.2.0",
"react": "17.0.2",
"react-redux": "8.0.2",
This is a shared package in a Lerna monorepo setup.
Does anyone know what could be wrong here, what could lead to this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
React -Redux必须从您使用的任何React Conecler(ReactDom)或React Native中导入
批次
。它是通过有两个不同的文件从中导入的,并依靠捆绑器来查找batch.native.js
文件,如果您使用的是React Native。我的猜测是,关于您的构建设置的某些内容没有找到该文件,因此React-Redux默认要导入使用ReactDom的文件。
不幸的是,我对如何解决此问题没有任何立即的答案,但希望这将您指向正确的方向。
React-Redux has to import
batch
from whatever React reconciler you're using - either ReactDOM, or React Native. It does this by having two different files to import from, and relying on the bundler to find thebatch.native.js
file if you're using React Native.My guess is that something about your build setup is not finding that file, and so React-Redux is defaulting to importing the file that uses ReactDOM instead.
Unfortunately I don't have any immediate answers on how to fix this, but hopefully that points you in the right direction.