Skip to content

Instantly share code, notes, and snippets.

@ctrlplusb
Created November 5, 2018 20:07
Show Gist options
  • Save ctrlplusb/812993c2cb0160d22aaecd38fdb02395 to your computer and use it in GitHub Desktop.
Save ctrlplusb/812993c2cb0160d22aaecd38fdb02395 to your computer and use it in GitHub Desktop.
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