From c51c16de097c16a8c831898c1d69d30c6ddeb507 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 23 Dec 2022 16:10:42 -0800 Subject: [PATCH] Fix select not resetting on new views --- components/Select/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/Select/index.tsx b/components/Select/index.tsx index 99afae29..17867ee1 100644 --- a/components/Select/index.tsx +++ b/components/Select/index.tsx @@ -13,7 +13,6 @@ interface Props HTMLSelectElement > { open: boolean - placeholder?: string trigger?: React.ReactNode children?: React.ReactNode onClick?: () => void @@ -25,7 +24,8 @@ const Select = (props: Props) => { const [value, setValue] = useState('') useEffect(() => { - if (props.value) setValue(`${props.value}`) + if (props.value && props.value !== '') setValue(`${props.value}`) + else setValue('') }, [props.value]) function onValueChange(newValue: string) { @@ -33,8 +33,12 @@ const Select = (props: Props) => { if (props.onValueChange) props.onValueChange(newValue) } + console.log(value) return ( - +