Skip to content

Instantly share code, notes, and snippets.

@naveedahmed986
Last active December 29, 2020 13:55

Revisions

  1. naveedahmed986 revised this gist Dec 29, 2020. No changes.
  2. naveedahmed986 created this gist Dec 29, 2020.
    30 changes: 30 additions & 0 deletions store.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    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)