[英]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.