Skip to content

Commit

Permalink
add example for controlled component with allowCross false
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin-front committed Oct 26, 2017
1 parent 227a126 commit cc060cd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'rc-slider/assets/index.less';
import React from 'react';
import ReactDOM from 'react-dom';
import Slider from 'rc-slider';
import PropTypes from 'prop-types';

const Range = Slider.Range;

const style = { width: 400, margin: 50 };
Expand Down Expand Up @@ -93,6 +95,9 @@ class DynamicBounds extends React.Component {
}

class ControlledRange extends React.Component {
static propTypes = {
allowCross: PropTypes.bool,
}
constructor(props) {
super(props);
this.state = {
Expand All @@ -105,8 +110,9 @@ class ControlledRange extends React.Component {
});
}
render() {
const { allowCross = true } = this.props;
return (
<Range value={this.state.value} onChange={this.handleChange}/>
<Range value={this.state.value} onChange={this.handleChange} allowCross={allowCross}/>
);
}
}
Expand Down Expand Up @@ -154,6 +160,10 @@ ReactDOM.render(
<p>Controlled Range</p>
<ControlledRange />
</div>
<div style={style}>
<p>Controlled Range with not allowCross</p>
<ControlledRange allowCross={false} />
</div>
<div style={style}>
<p>Multi Range</p>
<Range count={3} defaultValue={[20, 40, 60, 80]} pushable />
Expand Down

0 comments on commit cc060cd

Please sign in to comment.