diff --git a/src/App.js b/src/App.js index c3652f7..a404a44 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,10 @@ import React from 'react' import { About, Tasks, Navbar } from './components' -const defaultState = { loading: true, search: '' } +const defaultState = { loading: true, tasks: [], search: '', newTask: '' } // hard-coded for now, but can be passed anything and set on state -const data = { user: { name: 'Scott', role: 'manager' }, component: 'tasks' } +const data = { user: { name: 'Scott', role: 'manager' }, component: 'tasks', tasks: ['arf', 'bruf', 'crap'] } class App extends React.Component { constructor() { @@ -13,6 +13,7 @@ class App extends React.Component { this.navigate = this.navigate.bind(this) this.handleChange = this.handleChange.bind(this) this.handleSubmit = this.handleSubmit.bind(this) + this.addTask = this.addTask.bind(this) } fetchData() { @@ -39,6 +40,14 @@ class App extends React.Component { console.log("Search term: ", this.state.search) this.setState({ search: ''}) } + + addTask(e) { + e.preventDefault() + console.log("Added task: ", e.target.value) + this.setState( { tasks: this.state.tasks.concat(this.state.newTask) }) + } + + renderLoading() { return
Your tasks:
+