Skip to content

Instantly share code, notes, and snippets.

@pflevy
Last active September 6, 2019 00:18
Show Gist options
  • Save pflevy/9ccbdd86a75d800446c549225c642c05 to your computer and use it in GitHub Desktop.
Save pflevy/9ccbdd86a75d800446c549225c642c05 to your computer and use it in GitHub Desktop.
Creating custom react hooks. Infinite scrolling example.
import React from "react";
const App = () => {
// Fetching fake data from an online API for this example
let tableContents = fetch("https://jsonplaceholder.typicode.com/todos/");
return (
<div>
<table>
<thead>
<tr>
<th>User ID</th>
<th>Title</th>
</tr>
</thead>
<tbody>
{tableContents.map(content => {
return (
<tr>
<td style={{ paddingTop: "10px" }}>{content.userId}</td>
<td style={{ paddingTop: "10px" }}>{content.title}</td>
</tr>
);
})}
</tbody>
</table>
</div>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment