preact-router
preact-router copied to clipboard
rerender on props.url change
resolves #330
Sorry for the super long delay in reviewing this @halcaponey! Just a few things I think we can address to get this merged.
Update looks good. Only thing I want to check is if this is triggering a double-render when changing the URL prop. Ideally we'd propagate the state without forcing a second render, since the router is already being re-rendered with the new URL as a prop.
The problem comes from !props.static
being always true
and since a change on the url prop triggers a setState which triggers a shouldComponentUpdate which returns true because the static prop is not defined.
What is the static prop used for ? It's only called in shouldComponentUpdate.
- If it's false or undefined, shouldComponentUpdate will always return true.
- if it's true then url prop and onChange prop will determine the result of shouldComponentUpdate