-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Slider] Add example showing how to access value
- Loading branch information
1 parent
cf4cf87
commit de9abe2
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
docs/src/app/components/pages/components/Slider/ExampleControlled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import Slider from 'material-ui/Slider'; | ||
|
||
export default class SliderExampleControlled extends React.Component { | ||
|
||
state = { | ||
firstSlider: 0.5, | ||
secondSlider: 50, | ||
} | ||
|
||
handleFirstSlider(event, value) { | ||
this.setState({firstSlider: value}); | ||
} | ||
|
||
handleSecondSlider(event, value) { | ||
this.setState({secondSlider: value}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Slider | ||
defaultValue={0.5} | ||
value={this.state.firstSlider} | ||
onChange={this.handleFirstSlider.bind(this)} | ||
/> | ||
<p> | ||
<span>{'The value of this slider is: '}</span> | ||
<span>{this.state.firstSlider}</span> | ||
<span>{' from a range of 0 to 1 inclusive'}</span> | ||
</p> | ||
<Slider | ||
min={0} | ||
max={100} | ||
step={1} | ||
defaultValue={50} | ||
value={this.state.secondSlider} | ||
onChange={this.handleSecondSlider.bind(this)} | ||
/> | ||
<p> | ||
<span>{'The value of this slider is: '}</span> | ||
<span>{this.state.secondSlider}</span> | ||
<span>{' from a range of 0 to 100 inclusive'}</span> | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters