Skip to content

Commit e9bd5e6

Browse files
committed
Replace fragment template to a function component
1 parent 32c324a commit e9bd5e6

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component} from 'react';
1+
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {defaultProps, propTypes} from '../components/{{cookiecutter.component_name}}.react';
44

@@ -9,33 +9,33 @@ import {defaultProps, propTypes} from '../components/{{cookiecutter.component_na
99
* It renders an input with the property `value`
1010
* which is editable by the user.
1111
*/
12-
export default class {{cookiecutter.component_name}} extends Component {
13-
render() {
14-
const {id, label, setProps, value} = this.props;
12+
const {{cookiecutter.component_name}} = (props) => {
13+
const {id, label, setProps, value} = props;
1514

16-
return (
17-
<div id={id}>
18-
ExampleComponent: {label}&nbsp;
19-
<input
20-
value={value}
21-
onChange={
22-
/*
23-
* Send the new value to the parent component.
24-
* setProps is a prop that is automatically supplied
25-
* by dash's front-end ("dash-renderer").
26-
* In a Dash app, this will update the component's
27-
* props and send the data back to the Python Dash
28-
* app server if a callback uses the modified prop as
29-
* Input or State.
30-
*/
31-
e => setProps({ value: e.target.value })
32-
}
33-
/>
34-
</div>
35-
);
36-
}
15+
return (
16+
<div id={id}>
17+
ExampleComponent: {label}&nbsp;
18+
<input
19+
value={value}
20+
onChange={
21+
/*
22+
* Send the new value to the parent component.
23+
* setProps is a prop that is automatically supplied
24+
* by dash's front-end ("dash-renderer").
25+
* In a Dash app, this will update the component's
26+
* props and send the data back to the Python Dash
27+
* app server if a callback uses the modified prop as
28+
* Input or State.
29+
*/
30+
e => setProps({ value: e.target.value })
31+
}
32+
/>
33+
</div>
34+
);
3735
}
3836

3937

4038
{{cookiecutter.component_name}}.defaultProps = defaultProps;
41-
{{cookiecutter.component_name}}.propTypes = propTypes;
39+
{{cookiecutter.component_name}}.propTypes = propTypes;
40+
41+
export default {{cookiecutter.component_name}};

0 commit comments

Comments
 (0)