Latest
@react-hook/latest
A React hook that updates useRef().current with the most recent value each invocation
Testing
react
react component
use-ref
use-latest
use-effect-callback
useeffect callback
@react-hook/latest
Testing
javascript
npm
Stars
1.5k
Weekly
566k
Open issues
38
Bundle
~25 kB
Installation
npm install @react-hook/latestCode example
import { Latest } from "@react-hook/latest";
export function Example() {
return (
<div>
<h2>Latest</h2>
<Latest />
</div>
);
}Pros & cons
Pros
- Actively maintained by Jared Lunde
- 566k weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 38 open issues on GitHub