[mapbox] fix viewport alterations (#3293)

* [mapbox] fix viewport alterations

Since explorev2 it appears that altering the viewport hasn't been
changing the controls as it used to. This PR addresses it.

* lint
This commit is contained in:
Maxime Beauchemin
2017-08-16 11:23:01 -07:00
committed by GitHub
parent d1d1c49009
commit ccf505a480
3 changed files with 14 additions and 15 deletions

View File

@@ -29,13 +29,10 @@ const defaultProps = {
export default class TextControl extends React.Component {
constructor(props) {
super(props);
const value = props.value ? props.value.toString() : '';
this.state = { value };
this.onChange = this.onChange.bind(this);
}
onChange(event) {
let value = event.target.value || '';
this.setState({ value });
// Validation & casting
const errors = [];
@@ -58,6 +55,7 @@ export default class TextControl extends React.Component {
this.props.onChange(value, errors);
}
render() {
const value = this.props.value ? this.props.value.toString() : '';
return (
<div>
<ControlHeader {...this.props} />
@@ -66,7 +64,7 @@ export default class TextControl extends React.Component {
type="text"
placeholder=""
onChange={this.onChange}
value={this.state.value}
value={value}
/>
</FormGroup>
</div>