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

Fix <SelectInput> throws error when fetching choices manually #9179

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Aug 14, 2023

Analysis

There are 2 problems:

  • useChoicesContext doesn't pass the isLoading prop to useList
  • useChoicesContext returns the isLoading prop it receives directly

This leads to a race condition where isLoading is already false while allChoices isn't updated yet (due to useEffect in useList).

Solution

Pass the isLoading from prop to useList, and return the isLoading from useList

Closes #9138

@fzaninotto fzaninotto added the RFR Ready For Review label Aug 14, 2023
@fzaninotto fzaninotto changed the title Fix SelectInput throws error when fetching choices manually Fix <SelectInput> throws error when fetching choices manually Aug 14, 2023
@djhi djhi added this to the 4.13.0 milestone Aug 14, 2023
@djhi djhi merged commit e3975c8 into master Aug 14, 2023
10 checks passed
@djhi djhi deleted the fix-selectinput-isloading branch August 14, 2023 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SelectInput does not support fetching remote choices with isLoading
2 participants