Skip to content

Instantly share code, notes, and snippets.

@Odonno
Created June 1, 2020 09:34
Show Gist options
  • Save Odonno/a9c5416ccfcf2e1f10bedbae1541f7bf to your computer and use it in GitHub Desktop.
Save Odonno/a9c5416ccfcf2e1f10bedbae1541f7bf to your computer and use it in GitHub Desktop.
State management comparison - recoil - hooks
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