UNPKG

zustand

Version:

🐻 Bear necessities for state management in React

16 lines (12 loc) 375 B
'use strict'; var ReactExports = require('react'); var shallow = require('zustand/vanilla/shallow'); const { useRef } = ReactExports; function useShallow(selector) { const prev = useRef(); return (state) => { const next = selector(state); return shallow.shallow(prev.current, next) ? prev.current : prev.current = next; }; } exports.useShallow = useShallow;