1.0.0 • Published 1 year ago
@guoyunhe/use-latest-ref v1.0.0
use-latest-ref
React hook to provide stable reference to latest props, state, options, etc.
Installation
npm i -S @guoyunhe/use-latest-refUsage
function Foobar(props) {
const propsRef = useLatestRef(props);
// you don't need to put props.foobar into dependencies and it is always the latest value
useEffect(() => {
propsRef.current.foobar;
}, []);
// ...
}1.0.0
1 year ago