Open filipac opened 1 year ago
You should be able to specify which part of the URL is used via the location prop: https://recoiljs.org/docs/recoil-sync/api/RecoilURLSync#url-location.
But if that doesn't work, you can also write your own serializer: https://recoiljs.org/docs/recoil-sync/api/RecoilURLSync#custom-serialization
Hello,
I use
RecoilURLSyncJSON
to sync an atom to the url and have a customread
andwrite
set for thesyncEffect
.The problem I discovered is that when I have an url with a hash at the end (eg: using HashRouter from react-router-dom), the read function is not called.
Example: if the url is
https://example.com/?hr-brand_id=[3254]#/
the read function is not called BUT if the url ishttps://example.com/?hr-brand_id=[3254]
the read function is called as expected and the state is read from the URL.Is there something I can do to make it call even if there is something in![image](https://user-images.githubusercontent.com/271155/203993134-b82a3ffc-93a7-4076-8959-f1cd7234b98d.png)
window.location.hash
? The browser correctly shows those 2 separated:Initially I though json parsing fails because #/ at the end is not valid JSON, but if parsing would be done using window.location.search, the parsing would have no problems even with a hash in the url.