Earlier I showed that I have an
<App> component that accepts a
pathname. On the server I pass it
req.url, in the browser I pass it
But now I want to update the pathname. So instead of using the prop directly, I will set the state to hold this pathname in the constructor.
When the URL changes, my listener will fire, being passed the new pathname, which I can use to update the state.
So now it looks like this:
Very simple routing without all the extra stuff.
If you’re interested, I tried to keep the change as simple as possible and did it in a single commit. But please, before you go and view the code, know that I originally wrote the site two years ago and thus contains none of the wisdom I have gathered over the last two years.
... read the whole story at hackernoon.com.