molefrog / wouter

🥢 A minimalist-friendly ~2.1KB routing for React and Preact
https://npm.im/wouter
The Unlicense
6.41k stars 146 forks source link

wouter Switch matches less-specific Route for 1 render when using browser 'back' button #464

Open doggan opened 2 weeks ago

doggan commented 2 weeks ago

Issue

Repro

Resources

Steps

  1. Go to characters/new route. The CharacterCreationPage component is correctly rendered.
  2. Click link to navigate to characters/123456 route. The CharacterPage component is correctly rendered.
  3. Click browser back button to go back to characters/new.
    • Actual: The CharacterPage component is rendered once with new as it's parameter id, and then the CharacterCreationPage component is rendered. You can see from the console.logs: image
    • Expected: The CharacterCreationPage should be rendered. The CharacterPage should not be rendered since the route doesn't match. You can see from the console.logs: image
      • Note: This "correct" behavior is achieved by clicking on a Link. The bug only happens when using the browser 'back' button.

Thank you for reading! I really appreciate the work put into this library. This has been the one small issue I've encountered so far.