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

144
Views
¿Cómo pasar el objeto a la acción en slice?

Necesito pasar userId de usuario y el apodo de userNickname a la acción authUser en el reductor de authSlice .

authSlice:

 import { createSlice } from '@reduxjs/toolkit'; const initialState = { userId : null, userNickame : "", isAuth : false, isAdmin : false, } export const authSlice = createSlice({ name : 'auth', initialState, reducers : { authUser : (state, action) => { //const {userId, userNickame} = action.payload; state.userId = userId; state.userNickame = userNickame; state.isAuth = true; }, }, }) export const { authUser } = authSlice.actions export default authSlice.reducer

llamando al despachador

 //... const dispatch = useDispatch(); const userId = useSelector((state) => state.userId); const userNickname = useSelector((state) => state.userNickname); //... dispatch(authUser(/* I need to pass userId and userNickname here */));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente

dispatch(authUser({ userId, userNickname }));

que es equivalente a

dispatch(authUser({ userId: userId, userNickname: userNickname }));

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!