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

169
Views
¿Qué es la noción de objeto de mapa extraReducers?

Cuando leí el documento oficial del kit de herramientas de redux, vi esto en la sección createSlice :

 const incrementBy = createAction('incrementBy') createSlice({ name: 'counter', initialState: 0, reducers: {}, extraReducers: { [incrementBy]: (state, action) => {. ///what is this return state + action.payload }, 'some/other/action': (state, action) => {}, }, })

No entiendo por qué tenemos array aquí. ¿Por qué usamos string aquí y por qué usamos esto en una matriz ( [incrementBy ])?

Ayuda por favor, muchas gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto no es una matriz, sino propiedades calculadas. Esto agregará key a un objeto en tiempo de ejecución

 let prop = "name"; const obj = { [prop]: "Stackoverflow", }; console.log(obj);

extraReduce es un objeto y en el código incrementBy dará el nombre de la propiedad, también está asignando una función a ese nombre de propiedad.

 let prop = "getSum"; const obj = { [prop]: (arr) => { return arr.reduce((acc, curr) => acc + curr, 0); }, }; console.log(obj[prop]([1, 2, 3, 4, 5])); console.log(obj.getSum([1, 2, 3, 4, 5]));

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!