hodcroftlab / covariants

Real-time updates and information about key SARS-CoV-2 variants, plus the scripts that generate this information.
https://covariants.org/
GNU Affero General Public License v3.0
316 stars 111 forks source link

feat: stateful URLs #279

Closed ivan-aksamentov closed 2 years ago

ivan-aksamentov commented 2 years ago

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 on RecoilRoot 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.

vercel[bot] commented 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