daily pastebin goal
5%
SHARE
TWEET

App

a guest Dec 13th, 2018 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import './App.css';
  3. import Box from './Components/Box';
  4. import Add from './Components/Add';
  5. import Todolist from './Components/Todolist';
  6.  
  7. class App extends Component {
  8.  
  9.   constructor(props) {
  10.     super(props);
  11.     this.state = {
  12.         lists: '',
  13.         inputValue: '',
  14.         itemArray: []
  15.     }
  16. }
  17.  
  18.   onAddTask = () => {
  19.     this.setState ({
  20.         lists: this.state.inputValue
  21.     });
  22.     const item = this.state.itemArray;
  23.     const title = this.state.lists;
  24.     item.push({ title  })
  25.     this.setState(prevState => ({
  26.       itemArray: [...prevState.lists, title]
  27.     }))
  28. }
  29.  
  30. updateInputValue = (event) => {
  31.   this.setState({
  32.     inputValue: event.target.value
  33.   });
  34. }
  35.  
  36.   render() {
  37.  
  38.     let length = this.state.itemArray.length;
  39.  
  40.     return (
  41.       <div className="App">
  42.         <Box createTodo = {
  43.           <div>
  44.             {this.state.itemArray.map((itemArr) => {
  45.               return (
  46.                 <div className="box">
  47.                   <Todolist tasks = {itemArr} />
  48.                 </div>
  49.               )
  50.             })}
  51.           </div>
  52.           }>
  53.         </Box>
  54.         <Add addTask = {this.onAddTask} inputValues = {this.updateInputValue} inputV = {this.state.inputValue}  />
  55.       </div>
  56.     );
  57.   }
  58. }
  59.  
  60. export default App;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top