Files
Folo/packages/internal/hooks/src/useRefValue.ts
T
Innei 4d746522f1 refactor: remove unused files and clean up project structure
- Deleted obsolete configuration files and unused components across various packages.
- Updated package.json files to reflect the removal of dependencies.
- Cleaned up code by removing unnecessary exports and unused imports in multiple modules.

Signed-off-by: Innei <tukon479@gmail.com>
2025-04-28 20:58:51 +08:00

16 lines
354 B
TypeScript

import { useLayoutEffect, useRef } from "react"
export const useRefValue = <S>(
value: S,
): Readonly<{
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
current: S extends Function ? S : Readonly<S>
}> => {
const ref = useRef<S>(value)
useLayoutEffect(() => {
ref.current = value
}, [value])
return ref as any
}