Closed robinprashanth closed 6 years ago
@robinprashanth The code should handle the case where
initialValue={undefined}
I think empty array should be fine as well.
Another option would be to simply not render super select at all if no options are available
I have to show super select even if it's not having any initialValue. If i pass empty array it breaks with error : name property was not found
Is there a reason you are not able to just leave initialValue undefined?
Undefined did the trick.Thanks for the help.
No problem @robinprashanth
I am working on a project were the select option is optional in the create form. In Edit form, I need to set initialValue based on the API response. Is there any option to pass empty array or object to reactsuperselect.
Example constructor(props) { super(props); this.state = { errors: {}, recNumberInitialValue: undefined }; } componentDidMount(){ getAPIrequest.then((resp) => thissetState({recNumberInitialValue: resp})) }
<ReactSuperSelect className="form-input" dataSource={this.recNumbers} onChange={this.recHandler} deselectOnSelectedOptionClick={false} initialValue={this.state.recNumberInitialValue} clearable={false} />
here recNumberInitialValue is undefined or a value based on the API response.
I am getting Failed prop type: Invalid prop
initialValue
supplied toReactSuperSelect
.Can you suggest If i can pass empty object or array as intialValue?