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

165
Views
Las variables de reacción no se actualizan

Tengo un estado y un reductor como tal:

 const [state, dispatch] = useReducer(reducer, initialAuthState);

Tengo una instancia de axios que creo así:

 const [client] = useState(() => { const newAxios = axios.create(); newAxios.interceptors.request.use((config) => { const local = localStorage.getItem(TOKEN_LOCALSTORAGE_KEY); if (local === null) return config; const token = JSON.parse(local).access_token; if(!config.url?.includes(HOST_URL)) config.url = HOST_URL + config.url; if (token && config.headers !== undefined) { config.headers.Authorization = `Bearer ${token}`; } dispatch({ type: "LOADING", value: true }); return config; }); newAxios.interceptors.response.use( (response) => { dispatch({ type: "LOADING", value: false }); return response; }, async (error) => { dispatch({ type: "LOADING", value: false }); const originalRequest = error.config; if (error.response === undefined) return Promise.reject(error); if (error.response.status === 401 && !originalRequest._retry) { originalRequest._retry = true; await refreshToken(); return newAxios(originalRequest); } return Promise.reject(error); } ); return newAxios;});

Cuando llamo a la función de envío para actualizar el valor de carga, nunca se actualiza y siempre permanece igual, incluso si uso una variable estándar con useState y actualizo usando setter, tampoco se actualiza. ¿Qué está pasando?

about 4 years ago · Juan Pablo Isaza
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!