Shit API & Select dynamic Options, how to set defaultValue ???
See original GitHub issueWhat problem does this feature solve?
Select dynamic Options, how to set defaultValue ???
I don’t know the first Option value, So how can I get set the default value using the first Option’s value ???
defaultValue="???"
// I don't know the first Option value,
// So how can I get set the default value using the first Option's value ???
What does the proposed API look like?
defaultValue={key===1}
just using key to set the defaultValue!
<Select
allowClear
placeholder="排序字段,支持排序组合"
onChange={this.onSelectSortKeyChange}
defaultActiveFirstOption
showSearch
defaultValue={key === 1}
// ??? Select dynamic Options, how to set defaultValue ???
>
{/*
Select.js:630 Uncaught TypeError: Cannot read property 'type' of null
*/}
{
[sort_items].map(
(sort_items) => {
let i = 0;
let arr = [];
for(let key in sort_items){
arr.push(
<Option
key={i}
value={key}>
{
sort_items[key]
}
</Option>
)
}
return arr;
}
)
}
</Select>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Set initial default value in Angularjs dynamic selector
If I put "Select value" first in the List from the back end, the selector initially shows/selects the last item in the list....
Read more >3 Ways to Set Default Value in JavaScript | SamanthaMing.com
Let's break down the 3 different ways to set Default Values using logical operator, ternary, ... Using Default Value as Function Parameter; Falsy...
Read more >Setting Default Value In Dropdown When Using Api To Filter ...
A dropdown menu for displaying choices an elegant alternative to the native <select> element. Specify the prop name of Option which will be...
Read more >Set a Default Value for a Dropdown Menu in Power Apps ...
In most modern apps, it's common to need to set a default choice in a dropdown menu. But how can you do this...
Read more >Set a Custom Default Value for the Drop Down lookup Control ...
In this episode, Chino shows you how to set a custom / first value for your drop down fields that are connected to...
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
shit api!
Select dynamic Options & defaultValue
https://github.com/ant-design/ant-design/issues/7292
solution