diff --git a/imports/ui/Plants.jsx b/imports/ui/Plants.jsx index 7d289d9..51f8870 100644 --- a/imports/ui/Plants.jsx +++ b/imports/ui/Plants.jsx @@ -1,7 +1,7 @@ import React from 'react' -import { Table } from 'react-bootstrap'; +import { Table, Button } from 'react-bootstrap'; -const Plants = ({plants}) => { +const Plants = ({plants, deletePlant}) => { return ( <> @@ -12,6 +12,7 @@ const Plants = ({plants}) => { Plant name Plant type + @@ -20,6 +21,7 @@ const Plants = ({plants}) => { return {plant.name} {plant.type} + }) } diff --git a/imports/ui/Settings.jsx b/imports/ui/Settings.jsx index ab0a3ae..b9b130f 100644 --- a/imports/ui/Settings.jsx +++ b/imports/ui/Settings.jsx @@ -24,6 +24,15 @@ class Settings extends React.Component{ }) } + deletePlant = (id) => { + let plants = this.state.plants.filter(plant =>{ // callback function + return plant.id !== id // when it returns false (the id is the same), it filters this object out of the array + }) + this.setState({ + plants: plants + }) + } + render(){ return ( <> @@ -39,7 +48,10 @@ class Settings extends React.Component{

- + @@ -48,7 +60,10 @@ class Settings extends React.Component{

- +