From f6454ab5997599947ed8ac3a36265b1256d9f74c Mon Sep 17 00:00:00 2001 From: Max <ḿax.seyfried@gmx.de> Date: Mon, 6 Jul 2020 11:17:59 +0200 Subject: [PATCH] added simple ids to plants --- imports/ui/Settings.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/ui/Settings.jsx b/imports/ui/Settings.jsx index b9b130f..7722784 100644 --- a/imports/ui/Settings.jsx +++ b/imports/ui/Settings.jsx @@ -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({