What are some alternatives to componentDidMount for registering store listeners and invoking actions on route transition?
|Added at||2016-05-06 23:05|
Say I have a user profile component being served by a react-router route.
In the path definition, a userid parameter is used to load the current user in the componentDidMount function.
But, now, introduce the idea that an administrator can edit other users' profiles as well as their own.
Currently, if an administrator is editing the profile of another user, and then directly attempts to route to their own profile, the userid parameter changes correctly. However, the component is not unmounted and remounted to trigger another profile load, meaning the content on the page reflects that of the old user's profile rather than the administrator's.
I've run into this issue a few times now and have been using workarounds with query strings and willReceiveProps. I fear that my use of react-router / reflux is archaic.