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

107
Views
¿Cómo obtener Arg personalizado en configureStore reducer?

Me gustaría proporcionar parámetros adicionales para Inyección de dependencia en Reducer.

Cuando creé la tienda, agregué argumentos como este.

 export default configureStore({ reducer, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: { extraArgument: { service } }, }).concat(logger), devTools: true, });

Sé cómo usarlo en la función createAsyncThunk, pero no sé cómo usarlo en otro Reducer. No hay un tercer parámetro.

En el siguiente caso, no hay un tercer factor.

 const authSlice = createSlice({ name: 'auth', initialState, reducers: { logout: (state, action, third) => { // third is undefiend!!! it doesn't get value. // but createAsyncThunk does const { extra} = third; const { service } = extra; service.authService.logout(); return { isLoggedIn: false, userId: null, profile: { name: null, }, token: null, }; } },
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Algo así como su service.authService.logout(); es un efecto secundario y los efectos secundarios nunca se permiten en un reductor de Redux. Un reductor solo puede leer state y la action y (en el caso de createSlice ) modificar state . No se permiten otros efectos secundarios. Así que nada como esto estará disponible en sus reductores.

Sin embargo, podría estar usando el middleware de escucha para esto.

 listenerMiddleware.startListening({ actionCreator: authSlice.actions.logout, effect: async (action, listenerApi) => { listenerApi.extra.authService.logout() }, })
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!