added simple ids to plants

This commit is contained in:
Max 2020-07-06 11:17:59 +02:00
parent 310418be7b
commit f6454ab599

View File

@ -1,7 +1,7 @@
import React from 'react'
import AddPlant from './AddPlant'
import Plants from './Plants'
import { Button, Form, Container, Row, Col, Table } from 'react-bootstrap';
import { Container, Row, Col} from 'react-bootstrap';
class Settings extends React.Component{
@ -15,8 +15,8 @@ class Settings extends React.Component{
// pass this function to the addplant comp as a prop
addPlant = (plant) => {
plant.id = Math.random(); // TODO rework
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({