File size: 2,621 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
## Removing `redux-saga`
**We don't recommend removing `redux-saga`**, as we strongly feel that it's the
way to go for most redux based applications.
If you really want to get rid of it, you will have to remove its presence from several places.
**app/configureStore.js**
1. Remove statement `import createSagaMiddleware from 'redux-saga'`.
2. Remove statement `const sagaMiddleware = createSagaMiddleware()`.
3. Remove `sagaMiddleware` from `middlewares` array.
4. Remove statement `store.runSaga = sagaMiddleware.run`
5. Remove `store.injectedSagas = {}; // Saga registry`
**app/tests/store.test.js**
1. Remove describe block and tests for `injectSagas`
2. Remove describe block and tests for `runSaga`
**app/utils**
1. Remove three files: `injectSaga.js`, `sagaInjectors.js`, and `constants.js`.
**app/utils/checkStore.js**
1. Remove `runSaga: isFunction,`
2. Remove `injectedSagas: isObject,`
**app/utils/tests**
1. Remove two files: `injectSaga.test.js` and `sagaInjectors.test.js`
**app/utils/tests/checkStore.test.js**
1. Remove `expect(() => checkStore({ ...store, injectedSagas: null })).toThrow();`
2. Remove `expect(() => checkStore({ ...store, runSaga: null })).toThrow();`
**app/containers/\*/index.js**
Clean up containers that inject a dynamic saga
1. Remove saga injections like: `const withSaga = injectSaga({ key: 'home', saga });`.
**Finally, remove it from the `package.json`. Then you should be good to go with whatever
side-effect management library you want to use!**
1. Remove `redux-saga` from `dependencies`
2. Remove `eslint-plugin-redux-saga` from `devDependencies`
3. Remove `eslintConfig > plugins > redux-saga`
4. Remove `eslintConfig > rules > redux-saga/*`
## Removing `reselect`
To remove `reselect`, remove it from your dependencies in `package.json` and then write
your `mapStateToProps` functions like you normally would!
You'll also need to hook up the history directly to the store. Make changes to `app/app.js`.
1. Remove statement `import { makeSelectLocationState } from 'containers/App/selectors'`
2. Make necessary changes to `history` as follows:
```js
const makeSelectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return state => {
const routingState = state.get('router'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: makeSelectLocationState(),
});
```
|