From d8df56fea78dd8a37ad3dbc438b5df693625562e Mon Sep 17 00:00:00 2001 From: Serhii Trofimets Date: Wed, 28 Jun 2023 20:57:11 +0300 Subject: [PATCH] update picker items on children change --- src/components/picker/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/picker/index.tsx b/src/components/picker/index.tsx index 85631ef712..dfff06d197 100644 --- a/src/components/picker/index.tsx +++ b/src/components/picker/index.tsx @@ -96,13 +96,13 @@ const Picker = React.forwardRef((props: PickerProps, ref) => { const {preset} = others; const [selectedItemPosition, setSelectedItemPosition] = useState(0); - const [items, setItems] = useState(propItems || extractPickerItems(themeProps)); + const pickerItems = propItems || extractPickerItems(themeProps); + const [items, setItems] = useState(pickerItems); useEffect(() => { - if (propItems) { - setItems(propItems); - } - }, [propItems]); + setItems(pickerItems); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [propItems, children]); const pickerExpandable = useRef(null);