-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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: warn when choices prop is undefined #8309
Conversation
@@ -161,6 +162,16 @@ export const SelectInput = (props: SelectInputProps) => { | |||
source: sourceProp, | |||
}); | |||
|
|||
warning( | |||
source === undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, as choices
will always be undefined here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both source
and allChoices
variables are set by useChoicesContext
just above this line. allChoices
is set asynchrounously (return value of useList hook) so there we have to check for isLoading !== true
before we throw. However, the source
variable is set synchronously either by prop or from ChoicesContext
and should be defined here.
@@ -161,6 +162,16 @@ export const SelectInput = (props: SelectInputProps) => { | |||
source: sourceProp, | |||
}); | |||
|
|||
warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component should throw if it cannot render, not warn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I'll change this also for the components from where I found this snippet.
Thanks! |
fixes #8308