admin管理员组文章数量:1026989
I have React ponent:
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={defaultOptions}
options={options}
/>
So options
and defaultOptions
is the same structure arrays {text: 'string, value: 'string'}
.
In semantic UI source code I found this:
/** Initial value or value array if multiple. */
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
])),
])
That the reason why my code above gives me error:
`Warning: Failed propType: Invalid prop `defaultValue` supplied to `Dropdown`. Check the render method of `View`.`
So question is how then I should set defaultValue for multi selection type of Dropdown?
I have React ponent:
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={defaultOptions}
options={options}
/>
So options
and defaultOptions
is the same structure arrays {text: 'string, value: 'string'}
.
In semantic UI source code I found this:
/** Initial value or value array if multiple. */
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
])),
])
That the reason why my code above gives me error:
`Warning: Failed propType: Invalid prop `defaultValue` supplied to `Dropdown`. Check the render method of `View`.`
So question is how then I should set defaultValue for multi selection type of Dropdown?
Share Improve this question edited Jun 2, 2017 at 15:43 Oleksandr Fediashov 4,3351 gold badge25 silver badges43 bronze badges asked Nov 7, 2016 at 19:24 Sarkis ArutiunianSarkis Arutiunian 1,2913 gold badges17 silver badges36 bronze badges1 Answer
Reset to default 6defaultValue cannot be an object for semantic-UI-react. It can only be a value. http://react.semantic-ui./modules/dropdown. If you look at the props of defaultValue, the docs say that it can be a string, number, or arrayOf.
I usually set mine to value of the dropdown - using immutabilityJS - when it is switched onChange.
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={dropdownList.get('forWhat')}
options={options}
onChange={(e, {value}) => this.updateDropdownList('forWhat',[value:value, text:"works"])}
/>
I have React ponent:
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={defaultOptions}
options={options}
/>
So options
and defaultOptions
is the same structure arrays {text: 'string, value: 'string'}
.
In semantic UI source code I found this:
/** Initial value or value array if multiple. */
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
])),
])
That the reason why my code above gives me error:
`Warning: Failed propType: Invalid prop `defaultValue` supplied to `Dropdown`. Check the render method of `View`.`
So question is how then I should set defaultValue for multi selection type of Dropdown?
I have React ponent:
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={defaultOptions}
options={options}
/>
So options
and defaultOptions
is the same structure arrays {text: 'string, value: 'string'}
.
In semantic UI source code I found this:
/** Initial value or value array if multiple. */
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
])),
])
That the reason why my code above gives me error:
`Warning: Failed propType: Invalid prop `defaultValue` supplied to `Dropdown`. Check the render method of `View`.`
So question is how then I should set defaultValue for multi selection type of Dropdown?
Share Improve this question edited Jun 2, 2017 at 15:43 Oleksandr Fediashov 4,3351 gold badge25 silver badges43 bronze badges asked Nov 7, 2016 at 19:24 Sarkis ArutiunianSarkis Arutiunian 1,2913 gold badges17 silver badges36 bronze badges1 Answer
Reset to default 6defaultValue cannot be an object for semantic-UI-react. It can only be a value. http://react.semantic-ui./modules/dropdown. If you look at the props of defaultValue, the docs say that it can be a string, number, or arrayOf.
I usually set mine to value of the dropdown - using immutabilityJS - when it is switched onChange.
<Dropdown
placeholder={field[propName].label}
id={propName}
fluid
multiple
selection
search
defaultValue={dropdownList.get('forWhat')}
options={options}
onChange={(e, {value}) => this.updateDropdownList('forWhat',[value:value, text:"works"])}
/>
本文标签:
版权声明:本文标题:javascript - Semantic-UI-React, selection, multi, can't set defaultValue - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1744115394a2082161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论