簡體   English   中英

錯誤:無法解析模塊react-redux / native

[英]Error: Unable to resolve module react-redux/native

我正在嘗試使用Redux的第一個react-native應用程序,並在設備上運行應用程序時收到以下錯誤消息,

“UnableToResolveError:無法從C:\\ project \\ Testing \\ index.android.js解析模塊react-redux / native:模塊映射或這些目錄中不存在模塊:C:\\ project \\ Testing \\ node_modules \\ react-終極版”

的package.json:

{
“名稱”:“測試”,
“版本”:“0.0.1”,
“私人”:是的,
“腳本”:{
“start”:“node node_modules / react-native / local-cli / cli.js start”,
“測試”:“開玩笑”
},
“依賴”:{
“反應”:“15.4.1”,
“本土反應”:“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”,
“開玩笑”:“18.1.0”,
“react-test-renderer”:“15.4.1”
},
“開玩笑”:{
“預設”:“反應原生”
}
}

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

請協助解決問題。

react-redux的index.js ,您可以直接通過react-redux導出Provider

所以你應該使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM