Skip to content

Instantly share code, notes, and snippets.

@naveedahmed986
Last active December 29, 2020 13:55
Show Gist options
  • Save naveedahmed986/8ce3f5c9beeac7b101ce84494e3a4585 to your computer and use it in GitHub Desktop.
Save naveedahmed986/8ce3f5c9beeac7b101ce84494e3a4585 to your computer and use it in GitHub Desktop.
react-loading-overlay react-redux store
import {createStore} from 'redux'
// Action Type
const LOADER = 'LOADER'
// Action
export const setLoader = (loading) => {
return {
type : LOADER,
payload : loading
}
}
// Reducer
const initialState = {
isLoading: false
}
const loadingActionReducer = (state = initialState, action) => {
switch(action.type) {
case LOADER: return {
...state,
isLoading : action.payload
}
default: return state
}
}
//Store
export const store = createStore(loadingActionReducer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment