Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

319
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!