diff --git a/imports/ui/AddPlant.jsx b/imports/ui/AddPlant.jsx index 4f5dae4..cd74f9a 100644 --- a/imports/ui/AddPlant.jsx +++ b/imports/ui/AddPlant.jsx @@ -23,6 +23,10 @@ class AddPlant extends React.Component{ handleSubmit = (e) => { e.preventDefault(); //console.log(this.state) + this.setState({ // reset state + name: '', + type: '' + }) this.props.addPlant(this.state) } diff --git a/imports/ui/Settings.jsx b/imports/ui/Settings.jsx index 7722784..e10c94e 100644 --- a/imports/ui/Settings.jsx +++ b/imports/ui/Settings.jsx @@ -16,7 +16,7 @@ class Settings extends React.Component{ // pass this function to the addplant comp as a prop addPlant = (plant) => { plant.id = this.state.plants.length + 1 // TODO rework - console.log(plant.id) + let plants = [...this.state.plants, plant]; // create a copy of the array and add the new plant to it this.setState({