From 2d6d1bc61878646c67a4199b9655e95f6cc9dc1f Mon Sep 17 00:00:00 2001 From: unix Date: Fri, 27 Mar 2020 00:38:13 +0800 Subject: [PATCH] fix(input): fix value update from controlled component --- components/input/input.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/input/input.tsx b/components/input/input.tsx index cd0217b..dc85152 100644 --- a/components/input/input.tsx +++ b/components/input/input.tsx @@ -40,7 +40,7 @@ const Input: React.FC = ({ className, ...props }) => { const theme = useTheme() - const [selfValue, setSelfValue] = useState(initialValue) + const [selfValue, setSelfValue] = useState(initialValue) const [hover, setHover] = useState(false) const { heightRatio, fontSize } = useMemo(() => getSizes(size),[size]) const labelClasses = useMemo( @@ -57,6 +57,7 @@ const Input: React.FC = ({ ) const changeHandler = (event: React.ChangeEvent) => { if (disabled || readOnly) return + setSelfValue(event.target.value) onChange && onChange(event) }