Question:
I’m using React Router Domv6
. So for my web application, I created a Redux action in userAction
called logoutUser
, and in view dashboard.jsx
, I added a logout button that should navigate me to the home page ('/')
. My problem is that clicking on logout does nothing, is my code wrong?userAction.js:
Answer:
logoutUser
is returning a function instead of executing the tasks you want. You either change it to:onClick
part, to the code below, so you execute the function retuned by logoutUser
:If you have better answer, please add a comment about this, thank you!