From 91ecdaa5dd1a65ff0ae944896945c0fe4bc23574 Mon Sep 17 00:00:00 2001 From: haishanh Date: Mon, 5 Nov 2018 18:32:16 +0800 Subject: update: convert more components to function ones includes Input, Config, SideBard. also removed react-redux Provider --- src/components/Input.js | 65 ++++++++----------------------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) (limited to 'src/components/Input.js') diff --git a/src/components/Input.js b/src/components/Input.js index 1d66214..f621b43 100644 --- a/src/components/Input.js +++ b/src/components/Input.js @@ -1,61 +1,16 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import s0 from './Input.module.scss'; -class Input extends Component { - static propTypes = { - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - type: PropTypes.string, - onChange: PropTypes.func, - name: PropTypes.string, - placeholder: PropTypes.string - }; - - static defaultProps = { - type: 'number', - placeholder: 'Please input' - }; - - state = { - value: this.props.value, - lastValueFromProps: this.props.value - }; - - static getDerivedStateFromProps(props, state) { - if (props.value !== state.lastValueFromProps) { - return { - lastValueFromProps: props.value, - value: props.value - }; - } - return null; - } - - handleInputOnChange = e => { - const value = e.target.value; - const int = parseInt(value, 10); - if (int < 0 || int > 65535) return; - this.setState({ value: e.target.value }); - }; - - render() { - const { onChange, name, type, placeholder } = this.props; - const { value } = this.state; - return ( -
- -
- ); - } +export default function Input(props) { + return ; } -export default Input; +Input.propTypes = { + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + type: PropTypes.string, + onChange: PropTypes.func, + name: PropTypes.string, + placeholder: PropTypes.string +}; -- cgit v1.3.1