UNPKG

809 BSource Map (JSON)View Raw
1{"version":3,"sources":["useValueHistory.js"],"names":["useValueHistory","value","history","current","push"],"mappings":";;;;;;;AAAA;;AAKA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD,EAAW;AACjC,MAAMC,OAAO,GAAG,mBAAO,EAAP,CAAhB;AAGA,wBAAU,YAAM;AACdA,IAAAA,OAAO,CAACC,OAAR,CAAgBC,IAAhB,CAAqBH,KAArB;AACD,GAFD,EAEG,CAACA,KAAD,CAFH;AAIA,SAAOC,OAAO,CAACC,OAAf;AACD,CATD;;eAWeH,e","sourcesContent":["import { useRef, useEffect } from 'react';\n\n/**\n * Accepts a variable (possibly a prop or a state) and returns its history (changes through updates).\n */\nconst useValueHistory = (value) => {\n const history = useRef([]);\n\n // quite simple\n useEffect(() => {\n history.current.push(value);\n }, [value]);\n\n return history.current;\n};\n\nexport default useValueHistory;\n"],"file":"useValueHistory.js"}
\No newline at end of file