9 lines
202 B
TypeScript
9 lines
202 B
TypeScript
import * as React from "react";
|
|
|
|
function useRefWithInit<T>(init: () => T): React.RefObject<T> {
|
|
const [ref] = React.useState(() => ({ current: init() }));
|
|
return ref;
|
|
}
|
|
|
|
export { useRefWithInit };
|