I have two pages named Login and Welcome. I noticed that I cant run dispatch before login. To be more understandable I leave an example below;
On Login Page dispatch(fetchUser())) doesn't trigger saga Login Page =>
const fetchUserLocal = () => {
console.log("dispatch run, before user login: ",dispatch(fetchUser()))
dispatch(fetchUser())
}
return ( <div> <button onClick={fetchUserLocal}>Click to FETCH USER</button> </div>)
On Welcome Page dispatch(fetchUser())) trigger the saga (The page can be accessible after logging in) Welcome Page =>
const fetchUserLocal = () => {
console.log("dispatch run, after user login: ",dispatch(fetchUser()))
dispatch(fetchUser())
}
return ( <div> <button onClick={fetchUserLocal}>Click to FETCH USER</button> </div>)
Both pages have useDispatch and action and I can reach on these pages. According to your request I can add more information, thanks for help