Skip to content

Instantly share code, notes, and snippets.

@JaysonChiang
Last active March 1, 2021 11:00
Show Gist options
  • Save JaysonChiang/7501c0dd0f905952932bc0bda1c77969 to your computer and use it in GitHub Desktop.
Save JaysonChiang/7501c0dd0f905952932bc0bda1c77969 to your computer and use it in GitHub Desktop.
import { useActions } from "./useActions";
const AddButton = () => {
const { addCount } = useActions();
const onClick = () => {
addCount();
};
return <button onClick={onClick}>+1</button>;
};
export default AddButton;
import { useDispatch } from "react-redux";
import { bindActionCreators } from "redux";
import { actionCreators } from "./action-creators";
export const useActions = () => {
const dispatch = useDispatch();
return bindActionCreators(actionCreators, dispatch);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment