From 837c14c9a6d764c10345ab1afaa3f28c41d3a340 Mon Sep 17 00:00:00 2001 From: Angela Montanye Date: Sun, 11 Nov 2018 09:42:49 -0700 Subject: [PATCH] make much smaller --- src/Dinos.js | 104 +++++++++++++------------------------------------- src/index.css | 3 ++ 2 files changed, 30 insertions(+), 77 deletions(-) diff --git a/src/Dinos.js b/src/Dinos.js index 533185a..8c70178 100644 --- a/src/Dinos.js +++ b/src/Dinos.js @@ -2,7 +2,7 @@ import React from 'react'; import { Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap'; -class Dinos extends React.Component{ +export default class Dinos extends React.Component{ constructor(){ super() this.state = { @@ -29,59 +29,59 @@ class Dinos extends React.Component{ } this.deleteDino = this.deleteDino.bind(this); this.handleChange = this.handleChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); + this.createDino = this.createDino.bind(this); } // ends constructor handleChange(event) { - //console.log(event.target.value) const name = event.target.name; this.setState({ [name]: event.target.value }); - // this.setState({value: event.name}); } - handleSubmit(event) { + createDino(event) { event.preventDefault(); - // let dummyDino = {name: 'Spinosaurus', height: '9ft', weight: '2000 kg', era: 'Pre Jesus', diet: 'Light Salad'} let dummyDino = {name: this.state.name, height: this.state.height, weight: this.state.weight, era: this.state.era, diet: this.state.diet} - //duplicate array let theDinos = this.state.dinosaurs.slice() theDinos.push(dummyDino) - console.log(theDinos) - //push to array - //.push(dummyDino) this.setState({dinosaurs: theDinos}) } deleteDino(name){ - // e.persist() let newDinos = this.state.dinosaurs.filter(dinosaur => dinosaur.name !== name) - //console.log(newDinos) this.setState({dinosaurs: newDinos}) } editDino(){ - + + } + readDinos(){ + this.dinoNames = this.state.dinosaurs.map((item)=> +
  • {item.name}

    +

    {item.height}

    +

    {item.weight}

    +

    {item.era}

    +

    {item.diet}

    + + +
  • + ) } + //Parameters: take in the user input + //Return: setting state of dino + //Example: user clicks edit and type T-Rex displays "T-Rex" + //Pseudo Code: make button + // onClick function that updates object + // Similar to createDino + // create read function + + //create a Form with: //input fields, submit button //populate that info on the page - render(){ - this.dinoNames = this.state.dinosaurs.map((item)=> - -
  • {item.name}

    -

    {item.height}

    -

    {item.weight}

    -

    {item.era}

    -

    {item.diet}

    - - - -
  • - ) + this.readDinos() return (
    @@ -111,32 +111,7 @@ class Dinos extends React.Component{ - - {/*
    - - - - - */} - - - {/* -
    */} +
    ); @@ -144,31 +119,6 @@ class Dinos extends React.Component{ }; -// class EssayForm extends React.Component { -// constructor(props) { -// super(props); -// this.state = { -// value: 'Please write an essay about your favorite DOM element.' -// }; - -// this.handleChange = this.handleChange.bind(this); -// this.handleSubmit = this.handleSubmit.bind(this); -// } -// render() { -// return ( -//
    -//