Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
use-sync-external-store
Advanced tools
Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.
The use-sync-external-store package provides a hook that allows React components to read from an external, synchronous data source and subscribe to updates from that source. It is designed to be a primitive hook for creating other hooks that need to subscribe to external data sources.
Subscribing to an external store
This feature allows you to create a custom hook that subscribes to an external store. The hook will re-render the component whenever the store updates.
import { useSyncExternalStore } from 'use-sync-external-store';
function useCustomHook(store) {
const state = useSyncExternalStore(
store.subscribe,
store.getSnapshot,
store.getServerSnapshot
);
return state;
}
React Redux provides a 'useSelector' hook that allows you to read data from a Redux store and subscribe to updates. It is similar to use-sync-external-store but is specifically tailored for Redux state management.
MobX React Lite offers 'useObserver' and other hooks to reactively work with MobX stores. It provides a way to connect React components to MobX observables, similar to how use-sync-external-store connects components to external stores.
Recoil provides a 'useRecoilValue' hook that subscribes to changes in an atom or selector, which is conceptually similar to use-sync-external-store's ability to subscribe to external data sources.
Zustand is a state management library that offers a hook-based API to subscribe to global state within React components. It is similar to use-sync-external-store in that it allows components to react to external state changes.
Backwards-compatible shim for React.useSyncExternalStore
. Works with any React that supports Hooks.
See also https://github.com/reactwg/react-18/discussions/86.
FAQs
Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.
The npm package use-sync-external-store receives a total of 10,573,689 weekly downloads. As such, use-sync-external-store popularity was classified as popular.
We found that use-sync-external-store demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.