preact-router icon indicating copy to clipboard operation
preact-router copied to clipboard

rerender on props.url change

Open halcaponey opened this issue 5 years ago • 3 comments

resolves #330

halcaponey avatar Aug 11 '19 07:08 halcaponey

Sorry for the super long delay in reviewing this @halcaponey! Just a few things I think we can address to get this merged.

developit avatar Oct 20 '19 21:10 developit

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.

developit avatar Oct 21 '19 13:10 developit

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

halcaponey avatar Oct 26 '19 18:10 halcaponey