Skip to content

Instantly share code, notes, and snippets.

@iamhaiderkhan
Created April 4, 2023 21:19
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 iamhaiderkhan/1d34623c82905a504ce17db85677bbeb to your computer and use it in GitHub Desktop.
Save iamhaiderkhan/1d34623c82905a504ce17db85677bbeb to your computer and use it in GitHub Desktop.
import { useSelector, useDispatch } from "react-redux";
import React from "react";
import * as actions from "./actions";
const ReduxHooksExample = () => {
const dispatch = useDispatch();
const counter = useSelector((state) => state.counter);
return (
<div>
<span>{counter.value}</span>
<button onClick={() => dispatch(actions.incrementCounter)}>
Counter +1
</button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment