Is it possible to use different query param in different components (by router) #2079
-
I currently use React-router-dom for router library, and I wanna use different query params in different path.
According to the doc, Router.tsx <BrowserRouter>
<Routes>
<Route path="/home" element={<Home />} />
<Route path="/home" element={<Book />} />
</Routes>
</BrowserRouter>, Home.tsx const Home = () => {
return (<RecoilURLSyncJSON storeKey="home-url" location={{part: 'queryParams'}}>
<div>Home!!></div>
// ... button etc
</RecoilURLSyncJSON>)
}
export default Home Book.tsx const Book = () => {
return (<RecoilURLSyncJSON storeKey="book-url" location={{part: 'queryParams'}}>
<div>Book!!></div>
// ... button etc
</RecoilURLSyncJSON>)
}
export default Book Both |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It should be the ancestor of all components which use the synced atom. So, you could provide different |
Beta Was this translation helpful? Give feedback.
It should be the ancestor of all components which use the synced atom. So, you could provide different
<RecoilURLSyncJSON>
components in different routes. Also, since your example has differentstoreKey
's, they can also both co-exist if necessary.