Use Callback Ref
use-callback-ref
The same useRef, but with callback
Hooks
react
hook
useRef
createRef
merge refs
use-callback-ref
Hooks
javascript
npm
frontend
Stars
309
Weekly
60M
Open issues
17
Bundle
~15 kB
Installation
npm install use-callback-refCode example
import { useCallbackRef } from "use-callback-ref";
export function Example() {
const value = useCallbackRef();
return <p>{String(value)}</p>;
}Pros & cons
Pros
- Actively maintained by theKashey
- 60M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~15 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 17 open issues on GitHub