Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nested route changes triggering parent guards #99

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

joshpensky
Copy link
Member

Description

The current way we are tracking route changes is through a changing location pathname; unfortunately, this location change is true for both parent and child nested routes, causing both guards to be triggered.

This PR introduces a new route change detection function, which checks the route path and params (instead of just comparing the location pathname)

Related issues

Fixes #59

What this does

  • Updates hasPathChanged -> hasRouteChanged, updates detection to check match.* instead of location.*
  • Removes null render for when route has changed but without guards
  • Updates intermediate demo to use nested route on Pokémon detail page
    • Updates RRDom to 5.3.0 to take advantage of the useRouteMatch hook helper

How to test

  1. Visit the intermediate demo
  2. Open a Pokémon page. Confirm the parent route loader appears, then the child route loader
  3. Click on a sublink in the page (Physique, Statistics, Moves). Confirm only the child route loader appears
  4. Click on a previous or next link. Confirm the parent route loader appears, then the child route loader

@joshpensky joshpensky added the bug Something isn't working label Sep 15, 2021
@joshpensky joshpensky self-assigned this Sep 15, 2021
@joshpensky joshpensky changed the base branch from main to develop September 15, 2021 15:06
@joshpensky joshpensky mentioned this pull request Sep 16, 2021
3 tasks
@joshpensky joshpensky marked this pull request as draft September 17, 2021 15:47
@joshpensky joshpensky added the work in progress Not ready yet for review label Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress Not ready yet for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The parent component gets reloaded when navigating between child/nested components
1 participant