Reputation: 5271
I've this code here:
<NativeSelect
classes={{
icon: classes.icon
}}
className={classes.select}
onChange={this.onVersionChange}
>
{
Object.keys(interface_versions).map(key => {
return <option key={key} value={key}
title={key}
className={classes.selectOption}
{...urlParams.get('ifversion') == key ? 'selected' : ''}
>
{key}
</option>
})};
</NativeSelect>
I've tried now to preselect an option during the creation if the key matches my URL parameter value but it's not working. Can you tell me why?
Upvotes: 0
Views: 285
Reputation: 22474
You can set the selected option by adding a value
property to the NativeSelect
component.
Something like this:
<NativeSelect
....
value={urlParams.get('ifversion')}
....
/>
.....
</NativeSelect>
Upvotes: 1