diff --git a/index.js b/index.js index d65bf4c0..88ea8349 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,6 @@ 'use strict'; - -import React,{ - PropTypes -} from 'react'; +import React from 'react' +import PropTypes from 'prop-types'; import { View, @@ -24,21 +22,21 @@ const propTypes = { data: PropTypes.array, onChange: PropTypes.func, initValue: PropTypes.string, - style: View.propTypes.style, - selectStyle: View.propTypes.style, - optionStyle: View.propTypes.style, - optionTextStyle: Text.propTypes.style, - sectionStyle: View.propTypes.style, - sectionTextStyle: Text.propTypes.style, - cancelStyle: View.propTypes.style, - cancelTextStyle: Text.propTypes.style, - overlayStyle: View.propTypes.style, - cancelText: PropTypes.string + style: PropTypes.object, + selectStyle: PropTypes.object, + optionStyle: PropTypes.object, + optionTextStyle: PropTypes.object, + sectionStyle: PropTypes.object, + sectionTextStyle: PropTypes.object, + cancelStyle: PropTypes.object, + cancelTextStyle: PropTypes.object, + overlayStyle: PropTypes.object, + cancelText: PropTypes.object }; const defaultProps = { data: [], - onChange: ()=> {}, + onChange: () => { }, initValue: 'Select me!', style: {}, selectStyle: {}, @@ -74,47 +72,47 @@ export default class ModalPicker extends BaseComponent { } componentDidMount() { - this.setState({selected: this.props.initValue}); - this.setState({cancelText: this.props.cancelText}); + this.setState({ selected: this.props.initValue }); + this.setState({ cancelText: this.props.cancelText }); } componentWillReceiveProps(nextProps) { - if (nextProps.initValue != this.props.initValue) { - this.setState({selected: nextProps.initValue}); - } + if (nextProps.initValue != this.props.initValue) { + this.setState({ selected: nextProps.initValue }); + } } onChange(item) { this.props.onChange(item); - this.setState({selected: item.label}); + this.setState({ selected: item.label }); this.close(); } close() { - this.setState({ - modalVisible: false - }); + this.setState({ + modalVisible: false + }); } open() { - this.setState({ - modalVisible: true - }); + this.setState({ + modalVisible: true + }); } renderSection(section) { return ( - - {section.label} + + {section.label} ); } renderOption(option) { return ( - this.onChange(option)}> + this.onChange(option)}> - {option.label} + {option.label} ) } @@ -129,10 +127,10 @@ export default class ModalPicker extends BaseComponent { }); return ( - + - + {options} @@ -140,7 +138,7 @@ export default class ModalPicker extends BaseComponent { - {this.props.cancelText} + {this.props.cancelText} @@ -150,7 +148,7 @@ export default class ModalPicker extends BaseComponent { renderChildren() { - if(this.props.children) { + if (this.props.children) { return this.props.children; } return ( @@ -163,9 +161,9 @@ export default class ModalPicker extends BaseComponent { render() { const dp = ( - - {this.renderOptionList()} - + + {this.renderOptionList()} + ); return (