Skip to content

Instantly share code, notes, and snippets.

@ctrlplusb
Created November 5, 2018 20:07
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 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