gpt4 book ai didi

reactjs - 错误: Unable to resolve module react-redux/native

转载 作者:行者123 更新时间:2023-12-03 13:40:41 26 4
gpt4 key购买 nike

我正在尝试使用 Redux 来尝试我的第一个 react native 应用程序,并在设备上运行该应用程序时收到以下错误消息,

"UnableToResolveError: Unable to resolve module react-redux/native from C:\project\Testing\index.android.js: Module does not exist in the module map or in these directories: C:\project\Testing\node_modules\react-redux"

package.json:

{
"name": "Testing",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.4.1",
"react-native": "0.40.0",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.1.0",
"react-test-renderer": "15.4.1"
},
"jest": {
"preset": "react-native"
}
}

index.android.js:

import React, { AppRegistry } from 'react-native';
import { Provider } from 'react-redux/native';
import App from './src/containers/App';
import configStore from './src/stores/configStore';
const store = configStore();
var TestingApp = React.createClass({
render () {
return (
...
);
}
});
AppRegistry.registerComponent('TestingApp', () => TestingApp);

请协助解决问题。

最佳答案

来自index.js of react-redux ,你可以得到 Provider 是由 react-redux 直接导出的。

因此,您应该使用 import { Provider } from 'react-redux' 而不是 import { Provider } from 'react-redux/native'

您还可以查看 here 中的示例.

关于reactjs - 错误: Unable to resolve module react-redux/native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41788385/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com