Last active
December 29, 2020 14:03
-
-
Save naveedahmed986/0aa2a32579db85267322a22688d55bcb to your computer and use it in GitHub Desktop.
react-loading-overlay react-redux app
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 LoadingOverlay from 'react-loading-overlay' | |
import './App.css'; | |
import {connect, useDispatch} from 'react-redux' | |
import {setLoader} from './store'; | |
function App(props) { | |
console.log(props.isActive) | |
const dispatch = useDispatch() | |
return ( | |
<LoadingOverlay | |
active={props.isActive} | |
spinner | |
text='Loading...' | |
> | |
<div className="App"> | |
<button onClick={()=> { | |
dispatch(setLoader(true)) | |
setTimeout(()=>{ | |
dispatch(setLoader(false)) | |
},2000) | |
}}>Load Spinner</button> | |
</div> | |
</LoadingOverlay> | |
); | |
} | |
const mapStateToProps = state => { | |
return { | |
isActive: state.isLoading | |
} | |
} | |
export default connect(mapStateToProps)(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment