Closed CrisLi closed 8 years ago
+1
A middleware should do the trick but i have the fealing, that it would be an overkill.
@cateland Yep, I think middleware is the way to go. Hook it in, and listen for the corresponding actions.
@CrisLi Maybe this will help you get started with middleware: https://medium.com/@meagle/understanding-87566abcfb7a#.ljplf19dz
As this is not really router issue, more like a 'reduxy' question, i will close this issue.
I am looking for a best way to remove some data from state when router changed. I have 3 containers (smart react components), each of them are not related. When I change the router to visit one of these page, I need to remove some data. For instance, the error message is showed in the container-1, then I go to the container-2. After some operations, I go back to container-1, then the message should be dismissed.
I saw a lot of issue/questions have been arised for
routerDidChange
. But there is not document to show how to use it correctly. In my case, should I userouterDidChange
? Do I have to addcomponentWillUnmount
to every containers and dispatch an action to remove the data?I just want my code more in the Redux way :)