Я пытаюсь использовать redux persist и response-redux в моем файле app.js, но я получаю следующую ошибку:
Инвариантное нарушение: Не удалось найти «store» ни вконтекст или реквизиты "Connect (приложение)".Либо оберните корневой компонент в a, либо явно передайте «store» в качестве реквизита «Connect (App)»
Вот код для моего файла app.js, где происходит ошибка.
import React from 'react';
import { Provider } from 'react-redux';
import StoreDetailsScreen from './screens/storeDetailsScreen';
import CustomerListScreen from './screens/customerListScreen';
import AddCustomerScreen from './screens/addCustomerScreen'
import AddTransactionsScreen from './screens/addTransactionScreen'
import TransactionListScreen from './screens/transactionListScreen'
import CustomerInfoScreen from './screens/CustomerInfoScreen'
import {connect} from 'react-redux'
import {daysFromTransaction} from './redux/reducer'
import {updateFrequency} from './redux/actions'
import {store, persistor} from './redux/store';
import { createSwitchNavigator, createStackNavigator, createMaterialTopTabNavigator } from 'react-navigation';
import {PersistGate} from 'redux-persist/integration/react'
const TransactionsNavigator = createMaterialTopTabNavigator({
AddTransactions: AddTransactionsScreen,
CustomerInfo: CustomerInfoScreen,
TransactionList: TransactionListScreen,
})
const CustomerNavigator = createStackNavigator({
CustomerList: CustomerListScreen,
AddCustomerForm: AddCustomerScreen,
Transactions: TransactionsNavigator,
});
const MainNavigator = createSwitchNavigator({
StoreDetailsForm: StoreDetailsScreen,
Customers: CustomerNavigator,
});
class App extends React.Component {
state = {
customers: this.props.customers,
isReady: false,
}
async componentWillMount() {
await Expo.Font.loadAsync({
'MaterialIcons': require('@expo/vector-icons/fonts/MaterialIcons.ttf')
});
updatedCustomers = this.state.customers.map(customer => {
let frequency = 0
currentDate = new Date()
customer.transactions.forEach(transaction => {
if (daysFromTransaction(transactionDate, currentDate) < 30)
frequency++;
})
return {
...customer,
frequency: frequency
}
})
this.props.updateFrequency([...updatedCustomers])
this.setState({isReady: true})
}
render() {
if (!this.state.isReady)
return <Expo.AppLoading/>
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<MainNavigator />
</PersistGate>
</Provider>
);
}
}
const mapStateToProps = state => {
customers: state.customers
}
export default connect(mapStateToProps,{updateFrequency: updateFrequency})(App)