@nex-ui/hooks
Version:
A collection of React Hooks for Nex UI components.
24 lines (20 loc) • 519 B
JavaScript
"use client";
;
var react = require('react');
/**
* A custom hook that returns a ref to the latest value.
* This is useful to avoid stale closures in event handlers or effects.
*
* @param value - The value to keep track of.
* @returns A ref object containing the latest value.
*
* @example
* ```tsx
* const latestValue = useLatest(someValue);
* ```
*/ const useLatest = (value)=>{
const ref = react.useRef(value);
ref.current = value;
return ref;
};
exports.useLatest = useLatest;