3
在[email protected]
我使用FormControl Input
屬性defaultValue
到指定Input
被廢棄在組合框中指定默認值的反應,引導
<Input type='select'
ref='templateSelect'
defaultValue={this.state.templateId}
onChange={this.handleTemplateChange}>
{options}
</Input>
應如何在[email protected]
處理選擇起始值(最新的)並且這裏應該使用的新組件FormControl
不提供這樣的屬性?
應該用value
代替嗎?
<FormControl type='select'
ref='templateSelect'
value={this.state.templateId}
onChange={this.handleTemplateChange}>
{options}
</FormControl>
或者,也許是這樣的:
value={this.state.templateId || 'default value'}
據正如我所看到的,「FormControl」的值屬性幾乎與常規的「input」值屬性相對應,所以使用值來設置默認值,如上所述,應該可以正常工作。我不會推薦'value = {this.state.templateId || 'default value'}',因爲如果您的更改處理程序將'this.state.templateId'設置爲解析爲'false'的東西,則輸入字段中顯示的值將是'默認值'。 –