|
15 | 15 | * <http://www.mongodb.com/licensing/server-side-public-license>. |
16 | 16 | */ |
17 | 17 |
|
18 | | -import PropTypes from 'prop-types'; |
19 | | -import React from 'react'; |
| 18 | +import React, {useState} from 'react'; |
20 | 19 | import { Input, Row, Col } from 'components/bootstrap'; |
21 | 20 | import { FormattedMessage } from 'react-intl'; |
22 | 21 |
|
23 | | -class Description extends React.Component { |
| 22 | +const Description = ({description, onUpdate}) => { |
24 | 23 |
|
25 | | - static propTypes = { |
26 | | - onUpdate: PropTypes.func, |
27 | | - }; |
| 24 | + const [state, setState] = useState({description: description}); |
28 | 25 |
|
29 | | - static defaultProps = { |
30 | | - description:'', |
| 26 | + const _onValueChanged = (field) => { |
| 27 | + return e => { |
| 28 | + setState({description: e.target.value}); |
| 29 | + onUpdate(field, e.target.value); |
| 30 | + }; |
31 | 31 | }; |
32 | 32 |
|
33 | | - state = { |
34 | | - description: this.props.description |
35 | | - }; |
| 33 | + return ( |
| 34 | + <Row> |
| 35 | + <Col md={2} style={{ marginTop: 5, marginBottom: 0 }}> |
| 36 | + <label className="pull-right" ><FormattedMessage id= "wizard.titleDescription" defaultMessage= "Description (optional)" /></label> |
| 37 | + </Col> |
| 38 | + <Col md={10}> |
| 39 | + <Input style={{minWidth: 600}} id="description" name="description" type="textarea" |
| 40 | + onChange={_onValueChanged("description")} defaultValue={state.description}/> |
| 41 | + </Col> |
| 42 | + </Row> |
| 43 | + ); |
| 44 | +} |
36 | 45 |
|
37 | | - _onValueChanged(field) { |
38 | | - return e => { |
39 | | - this.props.onUpdate(field, e.target.value); |
40 | | - }; |
41 | | - } |
42 | | - |
43 | | - render() { |
44 | | - return ( |
45 | | - <Row> |
46 | | - <Col md={2} style={{ marginTop: 5, marginBottom: 0 }}> |
47 | | - <label className="pull-right" ><FormattedMessage id= "wizard.titleDescription" defaultMessage= "Description (optional)" /></label> |
48 | | - </Col> |
49 | | - <Col md={10}> |
50 | | - <Input style={{minWidth: 600}} ref="description" id="description" name="description" type="textarea" |
51 | | - onChange={this._onValueChanged("description")} defaultValue={this.state.description}/> |
52 | | - </Col> |
53 | | - </Row> |
54 | | - ); |
55 | | - } |
| 46 | +Description.defaultProps = { |
| 47 | + description: '', |
| 48 | + onUpdate: () => {} |
56 | 49 | } |
57 | 50 |
|
58 | 51 | export default Description; |
0 commit comments