Skip to content

Instantly share code, notes, and snippets.

@zehan12
Created September 20, 2024 08:38
Show Gist options
  • Select an option

  • Save zehan12/fde808f1a7ae2ed8d6ea09f72ffa70f9 to your computer and use it in GitHub Desktop.

Select an option

Save zehan12/fde808f1a7ae2ed8d6ea09f72ffa70f9 to your computer and use it in GitHub Desktop.
import { useSelector, useDispatch } from "react-redux";
function MyReduxComponent() {
const count = useSelector((state) => state.counter);
const dispatch = useDispatch();
return (
<div>
<p>Count: {count}</p>
<button onClick={() => dispatch({ type: "INCREMENT" })}>Increment</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment