Created
November 5, 2018 20:07
-
-
Save ctrlplusb/812993c2cb0160d22aaecd38fdb02395 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { useStore, useAction } from 'easy-peasy'; | |
function TodoList() { | |
// ๐ Access state | |
const todos = useStore(state => state.todos.items) | |
// ๐ Access actions | |
const add = useAction(dispatch => dispatch.todos.add) | |
return ( | |
<div> | |
{todos.map((todo, idx) => <div key={idx}>{todo.text}</div>)} | |
<AddTodo onAdd={add} /> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment