[英]Error: Unable to resolve module react-redux/native
I am trying my first react-native application with Redux and on running the application on device getting below error message, 我正在尝试使用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" “UnableToResolveError:无法从C:\\ project \\ Testing \\ index.android.js解析模块react-redux / native:模块映射或这些目录中不存在模块:C:\\ project \\ Testing \\ node_modules \\ react-终极版”
package.json: 的package.json:
{ {
"name": "Testing", “名称”:“测试”,
"version": "0.0.1", “版本”:“0.0.1”,
"private": true, “私人”:是的,
"scripts": { “脚本”:{
"start": "node node_modules/react-native/local-cli/cli.js start", “start”:“node node_modules / react-native / local-cli / cli.js start”,
"test": "jest" “测试”:“开玩笑”
}, },
"dependencies": { “依赖”:{
"react": "15.4.1", “反应”:“15.4.1”,
"react-native": "0.40.0", “本土反应”:“0.40.0”,
"react-redux": "^5.0.2", “react-redux”:“^ 5.0.2”,
"redux": "^3.6.0", “redux”:“^ 3.6.0”,
"redux-thunk": "^2.2.0" “redux-thunk”:“^ 2.2.0”
}, },
"devDependencies": { “devDependencies”:{
"babel-jest": "18.0.0", “babel-jest”:“18.0.0”,
"babel-preset-react-native": "1.9.1", “babel-preset-react-native”:“1.9.1”,
"jest": "18.1.0", “开玩笑”:“18.1.0”,
"react-test-renderer": "15.4.1" “react-test-renderer”:“15.4.1”
}, },
"jest": { “开玩笑”:{
"preset": "react-native" “预设”:“反应原生”
} }
} }
index.android.js: 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);
Kindly assist to solve the issue. 请协助解决问题。
From index.js
of react-redux , you could get that Provider
is exported by react-redux
directly. 从react-redux的index.js
,您可以直接通过react-redux
导出Provider
。
So you should use import { Provider } from 'react-redux'
instead of import { Provider } from 'react-redux/native'
. 所以你应该使用import { Provider } from 'react-redux'
的import { Provider } from 'react-redux/native'
而不是import { Provider } from 'react-redux/native'
的import { Provider } from 'react-redux/native'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.