Skip to content

Instantly share code, notes, and snippets.

@tannerlinsley
Created February 4, 2019 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tannerlinsley/f83753dc9a60e89ec8f531f9a3d6ae37 to your computer and use it in GitHub Desktop.
Save tannerlinsley/f83753dc9a60e89ec8f531f9a3d6ae37 to your computer and use it in GitHub Desktop.
const useMyTodos = () => {
const [{ todos, myUserID }] = useStore()
// Only update when todos or myUserID updates
return useMemo(
() => todos.filter(todo =>
todo.userID === myUserID
),
[todos, myUserID]
)
}
const App = () => {
const todos = useMyTodos()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment