mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
Fix/1307 input on value change (#1309)
* fix(input): inner event handler implemented * chore(root): changeset added
This commit is contained in:
parent
5b343b6181
commit
ac605eb71f
5
.changeset/gorgeous-taxis-tickle.md
Normal file
5
.changeset/gorgeous-taxis-tickle.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/input": patch
|
||||
---
|
||||
|
||||
onValueChange returned value fixed, it nows return a plain string
|
||||
@ -179,9 +179,9 @@ const MyButton2 = extendVariants(Button, {
|
||||
});
|
||||
|
||||
export default function NextUIPerf() {
|
||||
const [textA, setTextA] = useState<string | undefined>("");
|
||||
const [textB, setTextB] = useState<string | undefined>("");
|
||||
const [textC, setTextC] = useState<string | undefined>("");
|
||||
const [textA, setTextA] = useState<string>("");
|
||||
const [textB, setTextB] = useState<string>("");
|
||||
const [textC, setTextC] = useState<string>("");
|
||||
|
||||
return (
|
||||
<div className="w-full p-24 gap-4 flex flex-col">
|
||||
|
||||
@ -58,7 +58,7 @@ export interface Props<T extends HTMLInputElement | HTMLTextAreaElement = HTMLIn
|
||||
/**
|
||||
* React aria onChange event.
|
||||
*/
|
||||
onValueChange?: (value: string | undefined) => void;
|
||||
onValueChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export type UseInputProps<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> =
|
||||
@ -86,10 +86,17 @@ export function useInput<T extends HTMLInputElement | HTMLTextAreaElement = HTML
|
||||
...otherProps
|
||||
} = props;
|
||||
|
||||
const handleValueChange = useCallback(
|
||||
(value: string | undefined) => {
|
||||
onValueChange(value ?? "");
|
||||
},
|
||||
[onValueChange],
|
||||
);
|
||||
|
||||
const [inputValue, setInputValue] = useControlledState<string | undefined>(
|
||||
props.value,
|
||||
props.defaultValue,
|
||||
onValueChange,
|
||||
props.value ?? undefined,
|
||||
props.defaultValue ?? undefined,
|
||||
handleValueChange,
|
||||
);
|
||||
|
||||
const Component = as || "div";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user