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

377
Views
redux-toolkit-> 'Se detectó un valor no serializable en una acción' al convertir el código de trabajo a redux-toolkit

Estoy tratando de cambiar una aplicación que estoy construyendo para usar Redux Toolkit, y he notado que aparece este error 'Se detectó un valor no serializable en una acción, en la ruta: type . Valor: ', también se vuelve indefinido en la herramienta de desarrollo redux en lugar de auth/registerFail esperado, el estado está cambiando como se esperaba.

 import axios from 'axios'; import { setAlert } from '../alerts/alertSlice'; const slice = createSlice({ name: 'auth', initialState: { token: localStorage.getItem('token'), isAuthenticated: null, loading: true, user: null, }, reducers: { registerSuccess: (state, action) => { const { payload } = action.payload; state.push({ payload, isAuthenticated: true, loading: false, }); }, registerFail: (state) => { localStorage.removeItem('token'); state.token = null; state.isAuthenticated = false; state.loading = false; state.user = null; }, }, }); const { registerSuccess, registerFail } = slice.actions; export default slice.reducer; // Register User export const register = ({ name, email, password }) => async (dispatch) => { const config = { headers: { 'comtent-Type': 'application/json', }, }; const body = JSON.stringify({ name, email, password }); try { const res = await axios.post('/api/users', body, config); dispatch({ type: registerSuccess, payload: res.data, }); } catch (err) { const errors = err.response.data.errors; if (errors) { errors.forEach((error) => dispatch(setAlert(error.msg, 'danger'))); } dispatch({ type: registerFail }); } };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Accidentalmente está utilizando las funciones del creador de acciones como tipos aquí.

Entonces, en lugar de

 dispatch({ type: registerSuccess, payload: res.data, });

hacer esto:

 dispatch(registerSuccess(res.data));
about 4 years ago · Juan Pablo Isaza 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!