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

Syncing NuclearJS state with React Router Query Params #166

Open
mindjuice opened this issue Sep 14, 2015 · 0 comments
Open

Syncing NuclearJS state with React Router Query Params #166

mindjuice opened this issue Sep 14, 2015 · 0 comments
Assignees
Labels

Comments

@mindjuice
Copy link

Has anyone done any work to sync NuclearJS state to React Router query parameters?

I currently do router.transitionTo() with the new URL query params whenever an action changes some state that is associated with a query param. The way I currently did it though, I need to put all my related state in the same module, which is not great (pretty sure I can fix this though).

Going the other way, when the URL changes for any reason (e.g., user presses Back, or types in a new URL) I hook off of React Router's willTransitionTo() and fire an action to update the state from the current URL parameters. I have a check in there to avoid making any changes if the URL parameters match the current state so I don't get an infinite cycle of changes.

Has anyone done any work to use this sort of pattern (or similar) in a cleaner way?

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

No branches or pull requests

3 participants