I'm currently using redux-optimistic-ui
to be able to render something immediately to the user while saving to the db.
Before a slice of my normalized redux store is saved in the db and returns an id, I generate a temporary id that is replaced once I get the server answer.
The problem I have is related to routing. Since ids are heavily used in routes in my app, when I generate the temp id, it is used in my url while I wait for the server answer.
I think the way to do it is to do something equivalent to history.replaceState
with the url containing the new server generated id.
I'm using react-router v4 and I'm not sure where to do it. It seems I cannot do it directly from the redux reducers. Should I have another UI reducer that listen to the SUCCESS
action and store the url to redirect too ? Or is there a cleaner way ?
Thanks !