Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
How could redux be implemented in React?

I would like to see examples of how redux is implemented in react.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could implement it in the following way: using the "Ducks" file structure for redux which is a way to modularize parts of a Redux application by bundling reducers, action types and action creators together in a way that is easy to understand and port

For example:

  • you create a file and call it what you want for example exampleReduxDucks inside that file you will order redux as follows: An initial state, some types, a reducer and the actions

     import axios from "axios" //initial state const initialState = { list: [], fetching: false } const API = process.env.REACT_APP_API_REST //types const GET_SUCCESS_REGISTER = 'GET_SUCCESS_REGISTER' const RUNNING = 'RUNNING' //reducer const reducer = (state = initialState, action) => { switch (action.type) { case RUNNING: return { ...state, fetching: true } case GET_SUCCESS_REGISTER: return { ...state, list: action.payload, fetching: false } default: return state } } export default reducer //actions export const sendDataRegisterAction = (bodyData) => async (dispatch) => { dispatch({ type: RUNNING }) const totalData = await new Promise((dataReturn, errorReturn) => { axios({ method: 'POST', url: `${API}/users/user/`, headers: { "Content-Type": "application/json" }, data: bodyData }) .then(res => { dataReturn(res.status) dispatch({ type: GET_SUCCESS_REGISTER, payload: res.data }) }) .catch(error => { console.log(error.response.data.message) errorReturn(error.response.data.message) }) }) return totalData }

This is a redux file in react, the reducer is a pure function that receives the current state and an action and returns the new state.

with dispatch what you do is "dispatch" or "send" the new state through a payload and that payload will be taken by the reducer to change the previous state to the new state.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda