Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
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's useSyncExternalStore
. Works with any React that supports hooks.
Until useSyncExternalStore
is documented, refer to 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 4,999,323 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.