feat: add reusable date and time picker primitives
This commit is contained in:
15
src/hooks/use-as-ref.ts
Normal file
15
src/hooks/use-as-ref.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user