Files
kandev/apps/web/components/task/simple/synchronize-input-value.ts
T
2026-07-23 14:01:44 +01:00

12 lines
362 B
TypeScript

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