my redux
import { createStore } from 'redux';
import { persistStore, persistReducer } from 'redux-persist'
import AsyncStorage from '@react-native-async-storage/async-storage';
import user from '../reducer/index';
const persistConfig = {
key: 'root',
Storage: AsyncStorage,
};
const persistedReducer = persistReducer(persistConfig, user())
export function user(
state = {
id: '',
id_karyawan: '',
name: '',
tema: '',
presensi: '',
color: '',
akun: '',
},
action,
) {
switch (action.type) {
case 'CHANGE/USER':
return { ...state, ...action.payload };
}
return state;
}`
export const store = createStore(user);
export const persistor = persistStore(user);`
this is my app.js
import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Router from './router';
import { PersistGate } from 'redux-persist/integration/react';
import { Provider } from 'react-redux';
import { Store,persistor } from './redux/store/index';
export default class App extends Component {
render() {
return (
<Provider store={Store}>
<PersistGate persistor={persistor} loading={null}>
<Router/>
</PersistGate>
</Provider>
)
}
}
const styles = StyleSheet.create({})
That means that at some point you are dispatching undefined - a common reason for that could be that one of your action creators is missing a return statement - unfortunately you did not share that code.
Generally I want to give you the feedback that you are writing an extremely outdated style of Redux here - modern Redux does not use switch..case reduces ACTION_TYPES, immutable reducer logic, hand-written action creators or createStore any more - and is only 1/4 of the code as a consequence. And all that since 2019. I would highly recommend you to follow the official Redux tutorial as many external tutorials are unfortunately hopelessly outdated.