react-redux 5.0.5中的导入提供程序会在react-native中导致空白屏幕

时间:2017-09-25 10:40:17

标签: react-native redux react-redux react-native-android

无论我是否在渲染代码中使用Provider,我都会看到一个空白屏幕。然后,我发现即使我只是从react-redux导入Provider,我也会得到一个空白屏幕。但是,如果我发表评论import { Provider } from 'react-redux',则应用程序可以成功运行。

根据官方回购邮件的建议,我已经检查了npm ls react没有安装任何重复的反应模块,反应还原的版本高于5,这应该与react-native一起使用。

我该如何解决这个问题? 感谢。

App.js:

import React from 'react';
import {
    Platform,
} from 'react-native';

import { Router, Scene } from 'react-native-router-flux';
import { Provider } from 'react-redux';
import Home from './pages/Home';
import Chat from './pages/Chat';

export default class App extends React.Component {
    render() {
        return (
            <Router>
                <Scene key='root' style={{paddingTop: Platform.OS === 'ios' ? 64 : 54}}>
                    <Scene key='home' title='Home' component={Home}/>
                    <Scene key='chat' title='Chat' component={Chat}/>
                </Scene>
            </Router>
        );
    }
}

Package.json依赖项:

"dependencies": {
    "async-storage": "^0.1.0",
    "body-parser": "^1.18.1",
    "classnames": "^2.2.5",
    "cookie": "^0.3.1",
    "es6-promise": "^4.1.1",
    "express": "^4.15.4",
    "firebase": "^3.9.0",
    "jsonwebtoken": "^8.0.1",
    "mkdirp": "^0.5.1",
    "moment": "^2.18.1",
    "mongoose": "^4.11.11",
    "morgan": "^1.8.2",
    "multer": "^1.3.0",
    "nodemailer": "^4.1.0",
    "normalizr": "^3.2.3",
    "object-assign": "^4.1.1",
    "passport": "^0.4.0",
    "passport-facebook": "^2.1.1",
    "passport-jwt": "^3.0.0",
    "prop-types": "^15.5.10",
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.0",
    "react-native-gifted-chat": "0.0.10",
    "react-native-router-flux": "^4.0.0-beta.21",
    "react-redux": "5.0.5",
    "react-router-redux": "^4.0.8",
    "redux": "^3.7.2",
    "redux-form": "^7.0.4",
    "redux-logger": "^3.0.6",
    "redux-persist": "^4.9.1",
    "redux-thunk": "^2.2.0",
    "serialize-javascript": "^1.4.0",
    "superagent": "^3.6.0",
    "validator": "^8.2.0",
    "webpack-isomorphic-tools": "^3.0.4"
  }
}

2 个答案:

答案 0 :(得分:0)

为什么不使用react的组件。看下面

import React, { Component } from 'react'

使用react-redux进行连接,如

import { connect } from 'react-redux'

export default connect(mapStateToProps, {sampleActionHere})(ComponentsName)

答案 1 :(得分:0)

我认为我已经通过将react-redux升级到5.0.6来解决了这个问题。