0

I have an action creator in redux like so:

export const sendInfo = data => async dispatch => {
    try {
        await dispatch({
            myCode
            },
        })
    } catch (e) {
        browserHistory.push('/error')
        return history.replace('/error)
    }
}

but the url is changing to /error but it's not changing the view. when I refresh the page it is hitting my error page.

how can I fix this?

Red Baron
  • 7,181
  • 10
  • 39
  • 86
  • Do you have a backend? If not, that is needed on page refresh and when navigating to site.com/subsite – PEPEGA Feb 26 '20 at 08:17
  • 1
    Can you share your router component? – Drew Reese Feb 26 '20 at 08:18
  • try setting a flag in your specific action (when the info is sent, set a flag) then in your component check that flag which is passed as a prop if it was true then do redirect in your component. I guess this https://stackoverflow.com/a/42985875/10877801 can help you – BlackSheep Feb 26 '20 at 08:23
  • @DrewReese I can do but it's interesting I have put a log in there and it never calls it again after the first time. perhaps that's why? – Red Baron Feb 26 '20 at 09:09
  • @blackSheep I tried this but the problem is for me `/error` is redirecting to the wrong page for some reason – Red Baron Feb 26 '20 at 09:11
  • hmm, without seeing your router component and your reducer and the main component you are referring to, it would be hard to say anything, I suggest you edit your question and share more code to give everyone a little bit more context – BlackSheep Feb 26 '20 at 11:36

0 Answers0