nareshbhatia / mobx-state-router

MobX-powered router for React apps
https://nareshbhatia.github.io/mobx-state-router/
MIT License
227 stars 30 forks source link

Disappear 'activeClassName' with search params. #63

Closed roman-lezhnin closed 4 years ago

roman-lezhnin commented 5 years ago

Hello. There is the next route:

{
    name: RoutesName.USER_LIST,
    pattern: '/users'
  }

But when the query string is sent /users?showDeleted=false, the activeClassName flies off.

nareshbhatia commented 4 years ago

Hi @cr7parker, this issue has been fixed in version 5.0.0-beta.4. The reason you were facing this issue is that the test for determining if a link is active was too strict - the entire RouterState had to match, including params and queryParams. I have now relaxed the test to only check for routeName which covers 80% of the cases. In special cases, if your test for determining the active class is more complex, you can now pass a isActive() function to the link. See here.

Please not that version 5 has a few breaking changes to simplify the APIs. You can find a change log here. Feedback welcome!