Skip to content

Instantly share code, notes, and snippets.

@tarun-nagpal-github
Created May 10, 2020 08:54
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 tarun-nagpal-github/6f92a5a8ba050c2a8047b425fc0002ab to your computer and use it in GitHub Desktop.
Save tarun-nagpal-github/6f92a5a8ba050c2a8047b425fc0002ab to your computer and use it in GitHub Desktop.
final-app.js
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>
&nbsp;&nbsp;&nbsp;
<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