added simple ids to plants
This commit is contained in:
parent
310418be7b
commit
f6454ab599
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import AddPlant from './AddPlant'
|
import AddPlant from './AddPlant'
|
||||||
import Plants from './Plants'
|
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{
|
class Settings extends React.Component{
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ class Settings extends React.Component{
|
|||||||
|
|
||||||
// pass this function to the addplant comp as a prop
|
// pass this function to the addplant comp as a prop
|
||||||
addPlant = (plant) => {
|
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
|
let plants = [...this.state.plants, plant]; // create a copy of the array and add the new plant to it
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user