Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
recoil-sync
Advanced tools
recoil-sync provides an add-on library to help synchronize Recoil state with external systems
The recoil-sync
package provides an add-on library to help synchronize Recoil state with external systems.
Please see the Recoil Sync Documentation
In Recoil, simple asynchronous data queries can be implemented via selectors or useEffect()
and atom effects can be used for bi-directional syncing of individual atoms. The recoil-sync
add-on package provides some additional functionality:
recoil-sync
and refine
help provide this functionality.The recoil-sync
library also provides built-in implementations for external stores, such as syncing with the browser URL.
The basic idea is that a syncEffect()
can be added to each atom that you wish to sync, and then a <RecoilSync/>
is added inside your <RecoilRoot>
to specify how to sync those atoms. You can use built-in stores such as <RecoilURLSyncJSON>
, make your own, or sync different groups of atoms with different stores.
Here is a simple example syncing an atom with the browser URL:
const currentUserState = atom<number>({
key: 'CurrentUser',
default: 0,
effects: [
syncEffect({ refine: number() }),
],
});
Then, at the root of your application, simply include <RecoilURLSyncJSON />
to sync all of those tagged atoms with the URL
function MyApp() {
return (
<RecoilRoot>
<RecoilURLSyncJSON location={{part: 'queryParams'}}>
...
</RecoilURLSyncJSON>
</RecoilRoot>
)
}
That's it! Now this atom will initialize its state based on the URL during initial load, any state mutations will update the URL, and changes in the URL (such as the back button) will update the atom. See more examples in the Sync Effect, Store Implementation, and URL Persistence guides.
Please see the Recoil installation guide and add recoil-sync
as an additional dependency. recoil-sync
also includes the refine
library.
Development of Recoil happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Recoil.
Recoil is MIT licensed.
FAQs
recoil-sync provides an add-on library to help synchronize Recoil state with external systems
The npm package recoil-sync receives a total of 18,927 weekly downloads. As such, recoil-sync popularity was classified as popular.
We found that recoil-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.