Skip to content

Commit

Permalink
moving all redux code to shared repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mcverter committed Jan 8, 2019
1 parent d16db34 commit 3e92560
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 41 deletions.
3 changes: 3 additions & 0 deletions packages/guttersnipe-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"license": "MIT",
"dependencies": {
"isomorphic-fetch": "^2.2.1",
"redux": "^4.0.1",
"redux-immutable-state-invariant": "^2.1.0",
"redux-logger": "^3.0.6",
"redux-saga": "^0.16.2"
}
}
2 changes: 2 additions & 0 deletions packages/guttersnipe-shared/redux/reducers/categorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export default function categorization(
categorizationFetchError: false
});
case types.CATEGORIES_SUCCESS:
console.log(categorization);
return Object.assign({}, categorization, {
isFetchingCategorization: false,
categorizationFetchError: false,
paragraph: action.categorization.paragraph
});
case types.CATEGORIES_FAILURE:

return Object.assign({}, categorization, {
isFetchingCategorization: false,
categorizationFetchError: true
Expand Down
1 change: 1 addition & 0 deletions packages/guttersnipe-shared/redux/reducers/shareable.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function shareables(
}
);
case types.SHAREABLE_LIST_SUCCESS:
console.log(shareables);
return Object.assign(
{},
{
Expand Down
35 changes: 17 additions & 18 deletions packages/guttersnipe-shared/redux/store/configureStore.dev.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "../reducers";
import createSagaMiddleware from "redux-saga";
import reduxImmutableStateInvariant from "redux-immutable-state-invariant";
import thunk from "redux-thunk";
import logger from "redux-logger";
import rootSaga from "../sagas/shareables";

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const sagaMiddleware = createSagaMiddleware();

module.exports = function configureStore(initialState) {
console.log("initial state", initialState);
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

return createStore(
rootReducer,
initialState.default,
composeEnhancers(applyMiddleware(thunk))
);
const store = createStore(
rootReducer,
// initialState,
composeEnhancers(applyMiddleware(
sagaMiddleware,
logger,
reduxImmutableStateInvariant()
))
);

sagaMiddleware.run(rootSaga);
export {store};

//
/* TODO: InitialState must match rootReducer
initialState,
composeEnhancers(
applyMiddleware(thunk, reduxImmutableStateInvariant(),
logger))
);
*/
};
26 changes: 3 additions & 23 deletions packages/web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import React, { Component } from "react";
import { Provider, connect } from "react-redux";
import { createStore, applyMiddleware } from "redux";
import rootReducer from "guttersnipe-shared/redux/reducers";
import createSagaMiddleware from "redux-saga";
import "./App.css";
import Router from "./routes";
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import { fetchAllShareablesRequestAction } from 'guttersnipe-shared/redux/actions/shareables';

import rootSaga from "guttersnipe-shared/redux/sagas/shareables";

const sagaMiddleware = createSagaMiddleware();
const store = createStore(rootReducer, applyMiddleware(sagaMiddleware));
sagaMiddleware.run(rootSaga);


import { Provider } from "react-redux";
import {store} from "guttersnipe-shared/redux/store/configureStore.dev";

class App extends Component {
componentWillMount() {
// this.props.fetchAllShareablesRequestAction();
}

render() {
return (
<Provider store={store}>
Expand All @@ -32,8 +16,4 @@ class App extends Component {
}
}

const mapStateToProps = state =>state;

export default
//connect(null, {fetchAllShareablesRequestAction})
(App);
export default App;

0 comments on commit 3e92560

Please sign in to comment.