Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update picker items on children change #2646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a possibility that children always change and therefor will always trigger setItems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why children should always change? can you please describe a use case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adimorwix
Did you get a chance to test it?


const pickerExpandable = useRef<ExpandableOverlayMethods>(null);

Expand Down