Created
August 5, 2019 15:56
-
-
Save jeffscottward/492f552e1c29f678ec701b7675d3c5ac to your computer and use it in GitHub Desktop.
Async function w/ useEffect
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
useEffect(() => { | |
// React.js recommends embedding self-executing async function w/ useEffect | |
(async function getit() { | |
// Fuzzy filter is also ready for filtering by 'name' field from payload of /comments | |
const result = await get("https://jsonplaceholder.typicode.com/todos"); | |
const jsonData = result.data; | |
defineInitialColumnSortStates(jsonData); | |
addButtonColumn(jsonData); | |
dispatch({ | |
type: "SET_DATA", | |
newData: jsonData | |
}); | |
dispatch({ | |
type: "SET_VISIBLE_DATA", | |
newVisibleData: jsonData | |
}); | |
})(); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment