is a react HOC that comes to be plugged into react components and the saga middleware saga, it allows to add the saga functions within the react component, also to start one or more saga(s) and possiblity to stop them.
npm install redux-saga-hoc``js``
npm install --save redux-saga-hoc
This assumes you are using npm as your package manager.
#### Entry.js
This part may differ for each of you.
`js
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import ConfigStore from './ConfigStore';
import rootComponent from './rootComponent';
const store = new ConfigStore();
ReactDOM.render(
document.getElementById('app-entry'),
);
``
jsclass ConfigureStore {
// all store logic
const sagaMiddleware = createSagaMiddleware();
Object.assign(this, reduxStore, {
runSaga: sagaMiddleware.run
});
}
``#### RootComponent.js
redux-saga-hoc takes in parameter the component and a array of sagas and when the component is mounted it launches the sagas passed in parametre
`js
import React, { Component } from 'react';
import HOCsaga from 'redux-saga-hoc';import { saga1, saga2, saga3 } from './sagas';
class RootComponent extends Component {
contructor(props) {
super(props);
}
render() {
return (
);
}
}
export default HOCsaga(RootComponent, [saga1, saga2, saga3]);```