import { useMemo } from 'react';
import { useSyncedRef } from '../useSyncedRef/index.js';
export function useHookableRef(initialValue, onSet, onGet) {
    const onSetRef = useSyncedRef(onSet);
    const onGetRef = useSyncedRef(onGet);
    return useMemo(() => {
        let v = initialValue;
        return {
            get current() {
                return onGetRef.current === undefined ? v : onGetRef.current(v);
            },
            set current(value) {
                v = onSetRef.current === undefined ? value : onSetRef.current(value);
            },
        };
    }, []);
}
