Last active
September 6, 2019 00:18
-
-
Save pflevy/9ccbdd86a75d800446c549225c642c05 to your computer and use it in GitHub Desktop.
Creating custom react hooks. Infinite scrolling example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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