UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

14 lines (10 loc) 371 B
import { useSyncExternalStore } from 'react'; import { useItemsContext } from '../ItemsProvider'; export default function useItemNode(itemKey: string) { const { getNode, subscribeItem } = useItemsContext(); return useSyncExternalStore( callback => subscribeItem(itemKey, callback), () => getNode(itemKey), () => getNode(itemKey) // SSR fallback ); }