Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a0bb61

Browse files
chenglouzpao
authored andcommitted
docs select value to control chosen option
1 parent c065b03 commit 6a0bb61

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/docs/06-forms.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,18 @@ For HTML, this easily allows developers to supply multiline values. However, sin
130130
```
131131

132132
If you *do* decide to use children, they will behave like `defaultValue`.
133+
134+
135+
### Why Select Value?
136+
137+
The selected `<option>` in an HTML `<select>` is normally specified through that option's `selected` attribute. In React, in order to make components easier to manipulate, the following format is adopted instead:
138+
139+
```javascript
140+
<select value="B">
141+
<option value="A">Apple</option>
142+
<option value="B">Banana</option>
143+
<option value="C">Cranberry</option>
144+
</select>
145+
```
146+
147+
To make an uncontrolled component, `defaultValue` is used instead.

0 commit comments

Comments
 (0)