UNPKG

@shopify/polaris

Version:

Shopify’s admin product component library

15 lines (12 loc) 349 B
import React, { useEffect } from 'react'; function useOnValueChange(value, onChange) { const tracked = React.useRef(value); useEffect(() => { const oldValue = tracked.current; if (value !== tracked.current) { tracked.current = value; onChange(value, oldValue); } }, [value, onChange]); } export { useOnValueChange };