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

URI with Query Params fails to match #170

Closed
joe-finreach opened this issue Feb 2, 2021 · 4 comments · Fixed by #173
Closed

URI with Query Params fails to match #170

joe-finreach opened this issue Feb 2, 2021 · 4 comments · Fixed by #173

Comments

@joe-finreach
Copy link

We recently upgraded to 2.7.2, and the pagination for our routes broke. When we tested what had changed, we discovered that when we added a query param to any route, the route was not matched. For example, if we had a route people/admin that rendered an Admin panel with a list of people, when we navigated to page two people/admin?page=2 the default route (404) showed. Downgrading wouter to 2.7.1 solved the problem for us.

@molefrog
Copy link
Owner

molefrog commented Feb 2, 2021

Hi @joe-finreach! Thanks for reporting.

Could you share a piece of code that broke in your app?

@joe-finreach
Copy link
Author

joe-finreach commented Feb 2, 2021

Hi @molefrog I'm happy to share some code. Below is a snippet of (something like) the basic routing we had setup. This code works fine in 2.7.1, but renders the ErrorPage when accessing a URI like http://www.oursite.com/people?page=2 in 2.7.2

      <Switch>
        <Route path="/people" component={People} />
        <Route path="/courses" component={Courses} />
        <Route path="/goals" component={Goals} />
        <Route>
          <ErrorPage code="404" message="Page Not Found" />
        </Route>
      </Switch>

@molefrog
Copy link
Owner

molefrog commented Feb 2, 2021

Thanks, I think I've spotted the source of the problem already. It's this line:

prevPath.current !== pathname && update((prevPath.current = pathname));

I guess it should be instead:

prevPath.current !== pathname && prevPath.current = pathname && update(currentPathname(base)); 

Was recently changed in #169

@molefrog
Copy link
Owner

molefrog commented Feb 5, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants