diff --git a/src/components/TaskList.js b/src/components/TaskList.js index 15acb5dab04faf1974285a32e7f7b56efc8e04a8..1a6e7f0a4ee86964c793948020981a84e9eb38c9 100644 --- a/src/components/TaskList.js +++ b/src/components/TaskList.js @@ -47,6 +47,7 @@ class TaskList extends React.Component{ return ReactDOM.createPortal( <div className='tasklist'> + <h1>Tasklist</h1> {token && <div className='task-form'> <input type='text' placeholder='Task name' value={this.state.taskName} onChange={(e) => this.setState({taskName: e.target.value})}></input> diff --git a/src/components/TaskListButton.js b/src/components/TaskListButton.js index 31c98e931162dcbc4efa68236b068e5f8e2ad5cc..045e6c168abe6bb4b804a96f5356a2b0fafaa22e 100644 --- a/src/components/TaskListButton.js +++ b/src/components/TaskListButton.js @@ -6,19 +6,29 @@ class TaskListButton extends React.Component{ super(props); this.state = { open: false, - newTasks: '0' + newTasks: 0 } this.handleClick = this.handleClick.bind(this); } + componentDidMount(){ + this.getNewTask(); + } + + getNewTask(){ + this.setState({ + newTasks: this.state.open ? 0 : this.state.newTasks + 1 + }); + } + handleClick = (e) => { this.setState({ open: !this.state.open },() =>{ // Set new task cout to zero when the tasklist opens if(this.state.open){ - this.setState({newTasks: '0'}) + this.setState({newTasks: 0}) } }); }