import { useCallback, useState } from 'react';
import { useSyncedRef } from '../useSyncedRef/index.js';
export function useFunctionalState(initialState) {
    const [state, setState] = useState(initialState);
    const stateRef = useSyncedRef(state);
    return [useCallback(() => stateRef.current, []), setState];
}
