[英]React native invariant violation error
我想在我的react-native应用程序中实现redux,我在App.js中导入了提供程序,但是当我将应用程序内容包装在<Provider store={store}></Provider>
它给了我这个错误:
Invariant Violation: Objects are not valid as a React child (found: object with .... object with keys {$$typeof, type, key, ref, props, _owner, _store}).
我知道我不能用return方法渲染对象,但是我应该怎么做,如何将应用程序连接到redux?
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
// import reducer from './reducers/index';
import TabNavigation from './navigation/TabNavigation';
import StackNavigation from './navigation/StackNavigation';
//const store = createStore(reducer, applyMiddleware(thunk));
export default class App extends React.Component{
render() {
return (
//<Provider store={store}>
<TabNavigation />
//</Provider>
);
}
}
现在已将其注释掉,并且可以正常工作,如果我取消注释,则会出现错误...
我看到这条线有问题。
// const store = createStore(reducer,applyMiddleware(thunk));
第二个参数是初始状态,您正在其中传递中间件。 看看这是否可以解决。
如果那不能解决问题,那么问题将出在组件TavNavigation正在渲染中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.