-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the content of the fragments file
- Loading branch information
Showing
1 changed file
with
5 additions
and
41 deletions.
There are no files selected for viewing
46 changes: 5 additions & 41 deletions
46
...okiecutter.project_shortname}}/src/lib/fragments/{{cookiecutter.component_name}}.react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,5 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {defaultProps, propTypes} from '../components/{{cookiecutter.component_name}}.react'; | ||
|
||
/** | ||
* ExampleComponent is an example component. | ||
* It takes a property, `label`, and | ||
* displays it. | ||
* It renders an input with the property `value` | ||
* which is editable by the user. | ||
*/ | ||
const {{cookiecutter.component_name}} = (props) => { | ||
const {id, label, setProps, value} = props; | ||
|
||
return ( | ||
<div id={id}> | ||
ExampleComponent: {label} | ||
<input | ||
value={value} | ||
onChange={ | ||
/* | ||
* Send the new value to the parent component. | ||
* setProps is a prop that is automatically supplied | ||
* by dash's front-end ("dash-renderer"). | ||
* In a Dash app, this will update the component's | ||
* props and send the data back to the Python Dash | ||
* app server if a callback uses the modified prop as | ||
* Input or State. | ||
*/ | ||
e => setProps({ value: e.target.value }) | ||
} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
{{cookiecutter.component_name}}.defaultProps = defaultProps; | ||
{{cookiecutter.component_name}}.propTypes = propTypes; | ||
|
||
export default {{cookiecutter.component_name}}; | ||
{% if cookiecutter.component_type == "Function Component" -%} | ||
{%- include 'cookiecutter_templates/FunctionComponent.react.js' -%} | ||
{%- else -%} | ||
{%- include 'cookiecutter_templates/ClassComponent.react.js' -%} | ||
{%- endif -%} |