From 100b818684f97ecef2fb58f8a5db0b9d4533ede1 Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Sun, 9 Sep 2018 18:53:54 +0800 Subject: [PATCH 1/2] Update index.js --- index.js | 72 +++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/index.js b/index.js index d65bf4c0..b231732f 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, + style: PropTypes.any, + selectStyle: PropTypes.any, + optionStyle: PropTypes.any, + optionTextStyle: PropTypes.any, + sectionStyle: PropTypes.any, + sectionTextStyle: PropTypes.any, + cancelStyle: PropTypes.any, + cancelTextStyle: PropTypes.any, + overlayStyle: PropTypes.any, cancelText: PropTypes.string }; 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 ( From 7de0f06f80886672ea045205b5922c6f4a735e96 Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Sun, 9 Sep 2018 18:54:34 +0800 Subject: [PATCH 2/2] Update index.js --- index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index b231732f..88ea8349 100644 --- a/index.js +++ b/index.js @@ -22,16 +22,16 @@ const propTypes = { data: PropTypes.array, onChange: PropTypes.func, initValue: PropTypes.string, - style: PropTypes.any, - selectStyle: PropTypes.any, - optionStyle: PropTypes.any, - optionTextStyle: PropTypes.any, - sectionStyle: PropTypes.any, - sectionTextStyle: PropTypes.any, - cancelStyle: PropTypes.any, - cancelTextStyle: PropTypes.any, - overlayStyle: PropTypes.any, - 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 = {