Call function after dispatch from redux has finished

后端 未结 5 578
-上瘾入骨i
-上瘾入骨i 2020-12-14 20:48

All around it but not quite as I have enough of an idea of redux-thunk and of react-router but I am not getting this seemingly simple idea of:

5条回答
  •  再見小時候
    2020-12-14 21:22

    I want to highlight this section here...

     (
      
    )}>
    
    
    

    You want to call Login and push the history to the root of the application. You have a couple options here:

    1. call the function history.push('/') within your Login function, this looks to be within your reducer AUTHENTICATE function.

    2. dispatch an action that calls history.push after successful authentication look at redux-promise or redux-saga, redux-thunk is a bit trickier to do, but its possible

    I wouldn't try to do it any other way for the moment as you're dependant on login (which is called via redux, so I'd want to keep the logic in there, even though it's a client-side redirect).

提交回复
热议问题