Fix Select value/selected React warning

Summary:
React outputs the following error:
  Warning: Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.

This fixes it by using value instead of selected.

Reviewed By: danielbuechele

Differential Revision: D15535717

fbshipit-source-id: eb784ba2cdefe1c6744cc15592cd3e0191d237d0
This commit is contained in:
John Knox
2019-05-30 03:12:38 -07:00
committed by Facebook Github Bot
parent 79902cd7cb
commit 2221090037
2 changed files with 6 additions and 3 deletions

View File

@@ -698,7 +698,9 @@ export default class DatabasesPlugin extends FlipperPlugin<
obj[item] = item; obj[item] = item;
return obj; return obj;
}, {})} }, {})}
selected={String(this.state.selectedDatabase)} selected={
this.state.databases[this.state.selectedDatabase - 1]?.name
}
onChange={this.onDatabaseSelected} onChange={this.onDatabaseSelected}
/> />
<BoldSpan style={{marginLeft: 16, marginRight: 16}}>Table</BoldSpan> <BoldSpan style={{marginLeft: 16, marginRight: 16}}>Table</BoldSpan>

View File

@@ -56,9 +56,10 @@ export default class Select extends Component<{
grow={grow} grow={grow}
id={this.selectID} id={this.selectID}
onChange={this.onChange} onChange={this.onChange}
className={className}> className={className}
value={selected || ''}>
{Object.keys(options).map((key, index) => ( {Object.keys(options).map((key, index) => (
<option key={index} selected={key === selected}> <option value={options[key]} key={index}>
{options[key]} {options[key]}
</option> </option>
))} ))}