xxxxxxxxxx
//Component.js
import useDispatch from 'react-redux';//use dispatch is a way you dispatch actions
import getPosts from '../actions/';
//displatches an action
//code inside your component bellow
const dispatch= useDispatch();
dispatch(getPosts())
xxxxxxxxxx
import { useDispatch } from "react-redux";
import increment from "./action";
function Button() {
const dispatch = useDispatch();
const handleClick = () => {
dispatch(increment);
};
return (
<div>
<button onClick={handleClick}> Click here </button>
</div>
);
}
export default Button;