Created
June 1, 2020 09:34
-
-
Save Odonno/a9c5416ccfcf2e1f10bedbae1541f7bf to your computer and use it in GitHub Desktop.
State management comparison - recoil - hooks
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
export const useTodos = () => useRecoilValue(todoListState); | |
export const useLoadTodos = () => | |
useRecoilCallback( | |
async ({ set }) => { | |
const response = await fetch(`${apiUrl}/todos`); | |
const results = await response.json(); | |
return set(todoListState, results); | |
}, | |
[] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment