Dropdown: Receive Warning even requested props are given
See original GitHub issueSteps to Reproduce
- Copied “Search Selection” from react semantic-ui website
- Gathered options from database in requested format.
<Dropdown
onChange={this.setValue.bind(this)}
search
selection
options={this.state.worldOptions}
value={value}
placeholder="World"
/>
Expected
The Dropdown shouldn’t give any warnings.
Result
Dropdown works fine. Can do a search and select an option.
But it logs in console:
Warning: Failed prop type: selection
prop in Dropdown
requires props: options
.
Testcase If the docs show the issue, use: https://react.semantic-ui.com/modules/dropdown#dropdown-example-search-selection-two
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Warning: Failed prop type: Invalid prop `as` supplied to ` ...
You need to give a function or the name of a HTML element. You are returning a React Component. ( return (<UserPlate gravatar={image}/>)...
Read more >Dropdown
A dropdown can include a search prompt inside its menu. Dropdown state is not fully managed when using the subcomponent API. The shorthand...
Read more >DropDownListProps - React Dropdowns Library
DropDownListProps. Represents the props of the KendoReact DropDownList component. ... If valid is set, the required property will be ignored.
Read more >Form Select | Components
You can even define option groups with the options prop: Please select an option ... If both html and text are provided, html...
Read more >How to validate React props using PropTypes
If a component receives the wrong type of props, ... PropTypes.exact will give warnings if extra properties exist in a component: Component.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My easy way was doing like this
options={someOptions || []}
I found the problem. I was making async request in my componentWillMount lifecycle method. I was updating the state, and then using that state variable in my dropdown list.
The problem was produced because dropdown was rendered first with empty options before axios async request was done. But I was seeing the options anyway because axios returned a response and it was done so fast. So the warning was given for the first render in which the options variable was empty.