import React from 'react' import AddPlant from './AddPlant' import Plants from './Plants' import { Container, Row, Col} from 'react-bootstrap'; class Settings extends React.Component{ constructor(props){ super(props); this.state = { plants: [], types: ['Chile', 'Mint'], // hardcoded for now } } // pass this function to the addplant comp as a prop addPlant = (plant) => { plant.id = this.state.plants.length + 1 // TODO rework let plants = [...this.state.plants, plant]; // create a copy of the array and add the new plant to it this.setState({ plants: plants }) } 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 ( <>

Settings

Configurate your plant here. Based on your settings the smart garden will automate your plant environment.



); } } export default Settings;