UNPKG

zustand

Version:

🐻 Bear necessities for state management in React

13 lines (10 loc) 315 B
import React from 'react'; import { shallow } from 'zustand/vanilla/shallow'; function useShallow(selector) { const prev = React.useRef(undefined); return (state) => { const next = selector(state); return shallow(prev.current, next) ? prev.current : prev.current = next; }; } export { useShallow };