Skip to content
Advertisement

How to pass the object to action in slice?

I need to pass userId and userNickname to action authUser in authSlice reducer.

authSlice:

JavaScript

calling dispatcher

JavaScript

Advertisement

Answer

Simply

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

which is equivalent to

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

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement