16 lines
288 B
TypeScript
16 lines
288 B
TypeScript
import * as React from "react";
|
|
|
|
import { useIsomorphicLayoutEffect } from "@/hooks/use-isomorphic-layout-effect";
|
|
|
|
function useAsRef<T>(props: T) {
|
|
const ref = React.useRef<T>(props);
|
|
|
|
useIsomorphicLayoutEffect(() => {
|
|
ref.current = props;
|
|
});
|
|
|
|
return ref;
|
|
}
|
|
|
|
export { useAsRef };
|