Skip to content

Instantly share code, notes, and snippets.

@ayroblu
Created August 15, 2020 11:08
Show Gist options
  • Save ayroblu/cbe76d763cb0f27912a0593e0d8add7b to your computer and use it in GitHub Desktop.
Save ayroblu/cbe76d763cb0f27912a0593e0d8add7b to your computer and use it in GitHub Desktop.
const ConnectedComp = React.memo(() => {
const { state, dispatch } = React.useContext(context);
return (
<Comp
value={state.value1}
onClick={React.useCallback(
() => dispatch(actions.myAction({ value1: state.value1 + 1 })),
[dispatch, state.value1]
)}
/>
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment