Skip to content

Instantly share code, notes, and snippets.

@bewarusman
Created January 9, 2021 06:31
Show Gist options
  • Save bewarusman/01c0113485558dd667bb98750c79346f to your computer and use it in GitHub Desktop.
Save bewarusman/01c0113485558dd667bb98750c79346f to your computer and use it in GitHub Desktop.
import React from "react";
import DataTable from "./components/DataTable";
class App extends React.Component {
state = {
todos: [],
};
componentDidMount() {
fetch("https://jsonplaceholder.typicode.com/todos")
.then((res) => res.json())
.then((data) => this.setState({ todos: data, }));
}
render() {
return (
<DataTable>
{this.state.todos.map((todo) => (
<tr key={todo.id}>
<td>{todo.id}</td>
<td>{todo.title}</td>
<td>{todo.completed ? "Yes" : "No"}</td>
<td>
<button>Edit</button>
<button>Delete</button>
</td>
</tr>
))}
</DataTable>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment