You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been tinkering with this and its a nice setup but I don't quite understand how the router and component mount methods work. Whenever I click the 'Me' or 'John' profile links the route mounted stays at 1.
Checked it on the latest versions of firefox and safari. I added some breakpoints and found that the component mount methods are never invoked on clicking the profile links. Couldn't even to get it to stop on the App's handleRoute.
Have I misunderstood how this is meant to work? Any help appreciated, Thanks.
The text was updated successfully, but these errors were encountered:
Hi @mhussa - the "me" and "John" routes are handled by the same component. This means switching between the two actually doesn't unmount and remount, rather it's actually just re-rendering the <Profile /> component with new props.
If you add a componentWillReceiveProps() method to the Profile class you will be able to observe the behavior.
You can see an example of a much more fully built-out Profile component in the Nectarine source.
Thankyou for the quick response! yes it works exactly as you said.
I modified it as follows:
componentDidMount() {
// start a timer for the clock:
this.timer = setInterval(::this.updateTime, 1000);
this.updateTime();
}
componentWillReceiveProps() {
// every time we get remounted, increment a counter:
this.setState({ count: this.state.count+1});
}
Clicking on 'Home' remounts the component and the counter is back at 0, then clicking between profile views increments the count. The comment in the code about remounting threw me a bit.
I've been tinkering with this and its a nice setup but I don't quite understand how the router and component mount methods work. Whenever I click the 'Me' or 'John' profile links the route mounted stays at 1.
Checked it on the latest versions of firefox and safari. I added some breakpoints and found that the component mount methods are never invoked on clicking the profile links. Couldn't even to get it to stop on the App's handleRoute.
Have I misunderstood how this is meant to work? Any help appreciated, Thanks.
The text was updated successfully, but these errors were encountered: