import type { Dispatch, SetStateAction } from "react"; export function synchronizeInputValue( inputValueRef: { current: string }, setInput: Dispatch>, next: SetStateAction, ) { const nextValue = typeof next === "function" ? next(inputValueRef.current) : next; inputValueRef.current = nextValue; setInput(nextValue); }