Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
Reducer is not a function. React Native Redux

I am trying to add a reducer to my react native app. Here is the store constant:

export const USER_PROFILE = 'USER_PROFILE';

Here is the action.js

import {USER_PROFILE} from '../constants/index';

export function userProfile(userReducer) {
  return {
    type: USER_PROFILE,
    payload: {
      email: '',
    },
  };
}

This the userReducer that is causing the error. I keep getting an error of customerReducer is not a function.

import {USER_PROFILE} from '../constants/index';

const initialState = {
  userProfile: '',
};

const customerReducer = (state = initialState, action) => {
  switch (action.type) {
    case USER_PROFILE:
      return {
        ...state,
        userProfile: action.payload,
      };
    default:
      return state;
  }
};

export default customerReducer;

And I have declared the email as a state... const [email, setEmail] useState('')

calling the reducer here. const customerReducer = useSelector(state => state.userProfile); Now dispatching it with the useDispatch method.

const dispatch = useDispatch();
...
dispatch(customerReducer(email));
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your action.js should look somthing like this:

import {USER_PROFILE} from '../constants/index';

export function userProfile(userReducer) {
  return {
    type: USER_PROFILE,
    payload: {
      email: userReducer.email,
    },
  };

and when you dispatch you should use the action "userProfile" not the reducer "customerReducer". Your dispatch should look somthing like this:

dispatch(userProfile({email}));

make sure to use curly brackets. beacause you should pass an object not a string.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda