Skip to content

Commit

Permalink
Merge pull request #169 from plotly/component-updates
Browse files Browse the repository at this point in the history
Update function component
  • Loading branch information
T4rk1n authored Oct 18, 2024
2 parents 81fea22 + 5c71f95 commit 04ced3b
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@ import PropTypes from 'prop-types';
const {{cookiecutter.component_name}} = (props) => {
const {id, label, setProps, value} = props;

const handleInputChange = (e) => {
/*
* 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.
*/
setProps({ value: e.target.value });
};

return (
<div id={id}>
ExampleComponent: {label}&nbsp;
<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 })
}
onChange={handleInputChange}
/>
</div>
);
Expand Down

0 comments on commit 04ced3b

Please sign in to comment.