Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

321
Vistas
redux-persist undefined is not an object (evaluating 'action.type')

i use redux-persist for my project any help how i can fix this error I'm use Redux with ReactNative,I'd like to create a store with reducer And,I got error below, point to line 'switch (action.type)'

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({})
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

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.

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda