Skip to content

Instantly share code, notes, and snippets.

@codebucks27
Last active January 5, 2021 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codebucks27/9f7e3c06d5cb2a68a700c777f674cff6 to your computer and use it in GitHub Desktop.
Save codebucks27/9f7e3c06d5cb2a68a700c777f674cff6 to your computer and use it in GitHub Desktop.
import React, { useEffect, useState } from "react";
import "./style.css";
const renderData = (data) => {
return (
<ul>
{data.map((todo, index) => {
return <li key={index}>{todo.title}</li>;
})}
</ul>
);
};
function PaginationComponent() {
const [data, setData] = useState([]);
useEffect(() => {
fetch("https://jsonplaceholder.typicode.com/todos")
.then((response) => response.json())
.then((json) => setData(json));
}, []);
return (
<>
<h1>Todo List</h1> <br />
{renderData(data)}
</>
);
}
export default PaginationComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment