Last active
December 29, 2020 13:55
-
-
Save naveedahmed986/8ce3f5c9beeac7b101ce84494e3a4585 to your computer and use it in GitHub Desktop.
react-loading-overlay react-redux store
This file contains hidden or 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 {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