Skip to content

Instantly share code, notes, and snippets.

@ctrlplusb
Created February 8, 2019 00:23
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/fe1d85937941798f495476f9904260e7 to your computer and use it in GitHub Desktop.
Save ctrlplusb/fe1d85937941798f495476f9904260e7 to your computer and use it in GitHub Desktop.
export default function Todos() {
const items = useStore(state => state.todos.items);
// 👇
const save = useActions(actions => actions.todos.save);
const [newTodo, setNewTodo] = useState("");
return (
<div>
...
<button onClick={() => save(newTodo)}>Add</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment