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

isActive? #28

Closed
idolize opened this issue Sep 10, 2015 · 7 comments
Closed

isActive? #28

idolize opened this issue Sep 10, 2015 · 7 comments

Comments

@idolize
Copy link

idolize commented Sep 10, 2015

Is there a way to test if a specific route is active (similar to the IsActive mixin) via the router state in the Redux store (instead of a React component)?

I realize one option would be to get the location.pathname and check for a certain prefix using a RegExp, for example, but some kind of isActive function would be much cleaner.

@acdlite
Copy link
Owner

acdlite commented Sep 11, 2015

React Router has this module:

https://github.com/rackt/react-router/blob/master/modules/isActive.js

which could be used to create an isActive() selector. It's not a public API, so there's some risk involved in using it. But it may be our best option.

@idolize
Copy link
Author

idolize commented Sep 11, 2015

Hmm.. yeah, it would be great if react-router could decouple that checking logic into a publicly-accessible helper method.

Do you think this feature falls into scope for this (redux-react-router) library, or is it better off somewhere else?

@acdlite
Copy link
Owner

acdlite commented Sep 12, 2015

Yeah I think it falls within the scope of this library.

@i4got10
Copy link

i4got10 commented Sep 14, 2015

You can access history via context and call

this.context.history.isActive()

https://github.com/rackt/react-router/blob/v1.0.0-rc1/modules/Link.js

@acdlite
Copy link
Owner

acdlite commented Sep 14, 2015

@i4got10 Yes but we'd like to do it inside a selector, based purely on the state in the store.

@acdlite
Copy link
Owner

acdlite commented Sep 17, 2015

Closed by #56

@acdlite acdlite closed this as completed Sep 17, 2015
@idolize
Copy link
Author

idolize commented Sep 17, 2015

@acdlite Awesome! Thanks 😃

Do you happen to know if this method will let us check if a route is active regardless of the query, or does not specifying the query do a strict check for an empty query?

Checking if a route is active with any possible query can be useful sometimes.

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

No branches or pull requests

3 participants