Socket
Socket
Sign inDemoInstall

use-sync-external-store

Package Overview
Dependencies
3
Maintainers
2
Versions
1116
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    use-sync-external-store

Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.


Version published
Weekly downloads
6.7M
decreased by-18.81%
Maintainers
2
Install size
37.2 kB
Created
Weekly downloads
 

Package description

What is use-sync-external-store?

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.

What are use-sync-external-store's main functionalities?

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;
}

Other packages similar to use-sync-external-store

Readme

Source

use-sync-external-store

Backwards-compatible shim for React.useSyncExternalStore. Works with any React that supports Hooks.

See also https://github.com/reactwg/react-18/discussions/86.

FAQs

Last updated on 14 Jun 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc