Skip to content

Instantly share code, notes, and snippets.

@kalenpw
Created Apr 15, 2019
Embed
What would you like to do?
import React from 'react';
import Task from "./Task.js";
import NewTask from "./NewTask";
import styled from 'styled-components';
const TasksList = styled.ul`
li{
padding: 1px;
}
`
class TaskList extends React.Component {
constructor(props) {
super(props);
console.log(props.tasks);
}
generateTasks() {
// console.log(this.props.tasks);
let tasks = this.props.tasks.map((task) => {
console.log(task.id);
return (
<Task id={task.id} task={task}
editTask={this.props.editTask}
deleteTask={this.props.deleteTask}
isEditting={this.props.isEditting}
></Task>
)
});
return tasks;
}
render() {
const isEditting = this.props.isEditting;
// console.log(this.props.tasks);
return (
<TasksList>
{this.generateTasks()}
{
isEditting &&
<NewTask
projectId={this.props.projectId}
addTask={this.props.addTask}
></NewTask>
}
</TasksList>
)
}
}
export default TaskList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment