1.0.0 • Published 1 year ago

@guoyunhe/use-latest-ref v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

use-latest-ref

React hook to provide stable reference to latest props, state, options, etc.

Installation

npm i -S @guoyunhe/use-latest-ref

Usage

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