Open History to see the last commit
1import { useCommitOnBlur } from "~/hooks/useCommitOnBlur";
2import { Input, type InputProps } from "./input";
3
4export type DraftInputProps = Omit<InputProps, "value" | "onChange" | "defaultValue"> & {
5 readonly value: string;
6 readonly onCommit: (next: string) => void;
7};
8
9/**
10 * Prevents each keystroke from triggering a settings-wide re-render or a server RPC round-trip,
11 * which otherwise makes fields backed by a server-hydrated value feel laggy.
12 */
13export function DraftInput({ value, onCommit, ...rest }: DraftInputProps) {
14 const bag = useCommitOnBlur(value, onCommit);
15 return <Input {...rest} {...bag} />;
16}