Skip to content

Commit 493b37d

Browse files
author
xhlulu
committed
Replace {{cookiecutter.component_name}}.react.js with conditional inclusion
1 parent b3d50da commit 493b37d

File tree

1 file changed

+5
-61
lines changed

1 file changed

+5
-61
lines changed
Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,5 @@
1-
import React, {Component} from 'react';
2-
import PropTypes from 'prop-types';
3-
4-
/**
5-
* ExampleComponent is an example component.
6-
* It takes a property, `label`, and
7-
* displays it.
8-
* It renders an input with the property `value`
9-
* which is editable by the user.
10-
*/
11-
export default class {{cookiecutter.component_name}} extends Component {
12-
render() {
13-
const {id, label, setProps, value} = this.props;
14-
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-
);
35-
}
36-
}
37-
38-
{{cookiecutter.component_name}}.defaultProps = {};
39-
40-
{{cookiecutter.component_name}}.propTypes = {
41-
/**
42-
* The ID used to identify this component in Dash callbacks.
43-
*/
44-
id: PropTypes.string,
45-
46-
/**
47-
* A label that will be printed when this component is rendered.
48-
*/
49-
label: PropTypes.string.isRequired,
50-
51-
/**
52-
* The value displayed in the input.
53-
*/
54-
value: PropTypes.string,
55-
56-
/**
57-
* Dash-assigned callback that should be called to report property changes
58-
* to Dash, to make them available for callbacks.
59-
*/
60-
setProps: PropTypes.func
61-
};
1+
{%- if cookiecutter.use_async == "True" -%}
2+
{%- include 'cookiecutter_templates/AsyncComponent.react.js' -%}
3+
{%- else -%}
4+
{%- include 'cookiecutter_templates/Component.react.js' -%}
5+
{%- endif -%}

0 commit comments

Comments
 (0)