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

229
Views
Cómo manejar llamadas asíncronas en la aplicación redux react

Soy principiante en la aplicación de reacción. Necesito manejar llamadas asincrónicas en mi aplicación.

Para implementar la llamada asíncrona, ¿hay alguna biblioteca para eso?

¿Cómo implementar una llamada asíncrona usando la biblioteca?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Para implementar una llamada asíncrona, puede usar la siguiente biblioteca con react-redux

  1. redux-thunk
  2. redux-promesa
  3. redux-saga

Puede aprender el manejo asincrónico de llamadas utilizando la documentación de la biblioteca

over 4 years ago · Santiago Trujillo Report

0

Si está utilizando Vanilla ReactJS y su aplicación no necesita Flux o Redux para controlar el estado de la aplicación, puede usar el componentWillMount WillMount del método de ciclo de vida de React para eso con el método de fetch integrado o una biblioteca como axios

Si su aplicación necesita Flux o Redux , personalmente recomiendo Redux sobre Flux y puede usar el middleware redux-thunk para eso. por ejemplo

 const INCREMENT_COUNTER = 'INCREMENT_COUNTER'; function increment() { return { type: INCREMENT_COUNTER }; } function incrementAsync() { return dispatch => { setTimeout(() => { // Yay! Can invoke sync or async actions with `dispatch` dispatch(increment()); }, 1000); }; }

Para obtener más información, consulte http://redux.js.org/docs/advanced/AsyncActions.html

over 4 years ago · Santiago Trujillo Report

0

Aquí está la documentación sobre cómo usar acciones asíncronas: http://redux.js.org/docs/advanced/AsyncActions.html

Lo defines así al configurar la tienda:

 const store = createStore( rootReducer, applyMiddleware( thunkMiddleware ) )

Y lo usas en las acciones así:

 function fetchAction(data) { // Return a function, this function will be activated the the thunk middleware with dispatch as parameter return function (dispatch) { // Dispatch some action before fetch (like setting loading) dispatch(requestData(data)); // return a promise of the fetch return fetch('yoururl') .then(response => response.json()) .then(json => // dispatch a new action when you get your data dispatch(receivedData(data,json)) ).catch (e = > // you can also dispatch an error dispatch(errorData(data,e)); ) } }
over 4 years ago · Santiago Trujillo 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!