Created
January 14, 2020 18:13
-
-
Save rajputankit22/829370286fbb2bcf4ac1f88474d14e81 to your computer and use it in GitHub Desktop.
All Store files for redux.
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 { OPEN_DRAWER, CLOSE_DRAWER } from './types' | |
// Function for open Drawer | |
export const openDrawer = () => dispatch => { | |
dispatch({ | |
type: OPEN_DRAWER | |
}); | |
} | |
// Function for close Drawer | |
export const closeDrawer = () => dispatch => { | |
dispatch({ | |
type: CLOSE_DRAWER | |
}); | |
} |
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
// Define Types | |
export const OPEN_DRAWER = "OPEN_DRAWER" | |
export const CLOSE_DRAWER = "CLOSE_DRAWER" |
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 { createStore, applyMiddleware, compose } from 'redux'; | |
import thunk from 'redux-thunk' | |
import rootReducer from './reducers'; | |
const initialState = {}; | |
const middleware = [thunk]; | |
const store = createStore( | |
rootReducer, | |
initialState, | |
compose( | |
applyMiddleware(...middleware), | |
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | |
) | |
) | |
export default store; |
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 { OPEN_DRAWER, CLOSE_DRAWER } from '../actions/types' | |
const initialState = { | |
setOpen: false, | |
} | |
export default function (state = initialState, action) { | |
switch (action.type) { | |
case OPEN_DRAWER: | |
return { | |
...state, | |
setOpen: true, | |
}; | |
case CLOSE_DRAWER: | |
return { | |
...state, | |
setOpen: false, | |
}; | |
default: | |
return state | |
} | |
} |
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 { combineReducers } from "redux" | |
import drawerReducer from "./drawerReducer" | |
export default combineReducers({ | |
drawer: drawerReducer | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment