Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed94756

Browse files
committed
add select option for react js
1 parent b9feca6 commit ed94756

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- [SideNavigation Component with State Handle](react-js/SideNavigation)
2525
- [Team Component](react-js/team/Team.js)
2626
- [Array Interval Delay and Hide Previous Element](react-js/array-plus-delay.js)
27+
- [React Select Option](react-js/SelectOption.js)
2728
- [Not Found Page](react-js/NotFound.js)
2829

2930
## Python

‎react-js/SelectOption.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { Component } from 'react'
2+
3+
export default class SelectOption extends Component {
4+
state ={
5+
type: ""
6+
}
7+
render() {
8+
return (
9+
<div>
10+
<select name="name" onChange={(e) => this.setState({ type: e.target.value })}
11+
className="form-control">
12+
<option disabled selected value> Select an option </option>
13+
<option value="buy" selected={type === "buy" ? true : ""}>Buy</option> {/* selected option */}
14+
<option value="sell" selected={type === "sell" ? true : ""}>Sell</option>
15+
</select>
16+
</div>
17+
)
18+
}
19+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /