Closed ivan-aksamentov closed 2 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/hodcroftlab/covariants/AZUPV6jC3KpPRXA8vfYj4W8tGWxg
✅ Preview: https://covariants-git-feat-stateful-urls-hodcroftlab.vercel.app
Resolves #30
This PR moves state of {clusters} and of {region, continent, country} into Recoil atoms. This allows for simpler manipulation of these pieces of state and reduces amount of code needed to synchronize the links between countries and continents.
Recoil allows to apply effects when atoms are being mutated. In this PR this is used to update the URL parameters.
The reverse link from query params to the state is done using
initializeState()
functionality onRecoilRoot
component. This ensures that the state is restored from the URL params on app load.Similarly, we could persist the state in local storage and possibly other destinations. However this is not implemented in this PR.