简体   繁体   中英

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,

"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);

Kindly assist to solve the issue.

From index.js of react-redux , you could get that Provider is exported by react-redux directly.

So you should use import { Provider } from 'react-redux' instead of import { Provider } from 'react-redux/native' .

You can also check the example from here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM