useSelector useDispatcher - React Example
We can use useSelector and useDispatcher instead of using connect().
import React, { useEffect } from 'react';
import { useSelector, useDispatch } from "react-redux";
import './App.css';
import {dataAction} from './actions/getDataAction';
function App() {
const data = useSelector(state => state.dataReducer);
const dispatch = useDispatch();
useEffect(() => {
dispatch(dataAction())
});
return (
<div className="App">
<header className="App-header">
<h1>{data}</h1>
</header>
</div>
);
}
export default App;
Please find github project - https://github.com/codingtechlife/useSelector_useDispatcher_example
Thank you for sharing this informative post. looking forward to read more.
ReplyDeleteWeb Design and Development Company