Skip to content

Instantly share code, notes, and snippets.

@rajputankit22
Created January 14, 2020 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajputankit22/829370286fbb2bcf4ac1f88474d14e81 to your computer and use it in GitHub Desktop.
Save rajputankit22/829370286fbb2bcf4ac1f88474d14e81 to your computer and use it in GitHub Desktop.
All Store files for redux.
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
});
}
// Define Types
export const OPEN_DRAWER = "OPEN_DRAWER"
export const CLOSE_DRAWER = "CLOSE_DRAWER"
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;
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
}
}
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