Skip to content

Syncing NuclearJS state with React Router Query Params #166

Open
@mindjuice

Description

@mindjuice

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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions