mirror of
https://github.com/zoriya/v10.git
synced 2026-08-09 15:46:42 +00:00
18 lines
460 B
JavaScript
18 lines
460 B
JavaScript
"use client";
|
|
import { useRef } from "react";
|
|
//#region src/utils/use-latest-ref.ts
|
|
/**
|
|
* Keep a ref that always points to the latest value.
|
|
*
|
|
* Useful for capturing callbacks or derived values inside closures
|
|
* that are created once (e.g. factory callbacks) without stale reads.
|
|
*/
|
|
function useLatestRef(value) {
|
|
const ref = useRef(value);
|
|
ref.current = value;
|
|
return ref;
|
|
}
|
|
//#endregion
|
|
export { useLatestRef };
|
|
|
|
//# sourceMappingURL=use-latest-ref.js.map
|