remix URL does not get updated
Haroenv opened this issue · comments
Hi @Haroenv, thanks for your quick response, we solved the error follow your reply!
Now we have another issue, when we change the refinements, the url changed, but the
loader
of remix notreload
It makes me upset because we need to do some data transformation work on the
loader
according to the url.You can visit this sandbox: https://codesandbox.io/p/sandbox/wizardly-monad-g3s9ny?file=/app/components/Search.tsx:1,1
When you select one refinement, the url on the address bar changed, but not trigger the
reload
of remix loaderOriginally posted by @jason-rb2 in #5831 (comment)
Hi @jason-rb2,
That's expected, as React InstantSearch runs client-side after it's been server-side rendered and hydrated. This way it directly calls the Algolia servers for a faster search experience. Typically if users wanted to get data based on the search parameters they would do this client-side as well.
If you still need this page to be server-side rendered for each action done by the user, you can set the push
option of the history
router, and use for example navigate
from useNavigate
that's exported by Remix.
Here's a CodeSandbox showing how that would work : https://codesandbox.io/p/sandbox/goofy-blackwell-vtxy79?file=/app/components/Search.tsx:92,37
You can see serverUrl
does get updated.
It should be noted that in order for useNavigate
not to throw on the server due to limitations with getServerState
, I had <Search />
be wrapped by a MemoryRouter
, only in getServerState
from react-router
, which is what Remix is based on.
Based on the reactions, I assume this is solved, thanks!