Last active
December 2, 2019 08:02
-
-
Save shanebdavis/c8e72c11c048030256ddfbe5f1ecb050 to your computer and use it in GitHub Desktop.
Client-side-state for todo app (pseudo-react)
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
let list = [ | |
{ id: 1, text: "clean the house" }, | |
{ id: 2, text: "buy milk" } | |
]; | |
// REDUCERS | |
const _addItem = (list, item) => [...list, { ...item, id: uniqueId() }] | |
const _deleteItem = (list, item) => list.filter(todo => todo.id !== item.id) | |
// STUBS: | |
const useList = () => list // React hook | |
const deleteItem = (item) => null // dispatcher | |
const addItem = (item) => null // dispatcher |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment