import React from 'react' import { Button, Form } from 'react-bootstrap'; class AddPlant extends React.Component{ constructor(props){ super(props); this.state = { name: '', type: '' } } handleChange = (e) => { // console.log(e.target.id, e.target.value); // e.target.id reference to the state which is changed this.setState({ [e.target.id]: e.target.value }); } // search for arrow function for further syntax knowledge handleSubmit = (e) => { e.preventDefault(); //console.log(this.state) this.props.addPlant(this.state) this.setState({ // reset state name: '', type: '' }) } render (){ return ( <>
Name: {this.nameInput=(input)}} placeholder="plant" onChange={this.handleChange} /> Type: {this.props.typeArray.map((type, index) =>{ return })}
); } } export default AddPlant;