Passing props between routes
Is there a way to pass props between routes? From example navigating from route A to route B without setting params or search params. I saw state on Link and navigate but I didn't find something on docs. Is this type safe?
4 Replies
foreign-sapphire•2y ago
sounds like maybe you want to use a context?
quickest-silver•2y ago
Since the browser's history.state doesn't persist across a URL copy there wouldn't be a way to reliably offer that functionality without there having to be heavy caveats.
quickest-silver•2y ago
You could either persist some metadata to search, and derive the state you need using it.
Or, use React Context or a state manager like Zustand, Jotai, X-State, or Redux.
Or, perhaps just persist and read data using localStorage. This is a localStorage hook I use.
useLocalStorage
Discover how to use useLocalStorage from usehooks-ts
conscious-sapphireOP•2y ago
thank uuu