Created
May 10, 2020 08:54
-
-
Save tarun-nagpal-github/6f92a5a8ba050c2a8047b425fc0002ab to your computer and use it in GitHub Desktop.
final-app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './App.css'; | |
import { useSelector } from "react-redux"; | |
import { useDispatch } from "react-redux"; | |
function App() { | |
const globalState = useSelector(state => state); | |
const dispatch = useDispatch(); | |
const getUserData = () => { | |
// Get the Data for the User | |
dispatch({ type: "USER_FETCH_REQUESTED"}) | |
} | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
{/* Action will be triggred on clicked */} | |
<button onClick={getUserData} style={{fontSize: '20px'}}>Click here to Get Data</button> | |
| |
<h1>Hello Redux</h1> | |
<pre style={{fontSize: 20}}> | |
{JSON.stringify(globalState.userReducer, null, 2)} | |
</pre> | |
</header> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment