React Redux Saga - Работа с мультисагой - PullRequest
0 голосов
/ 12 сентября 2018

Я пытаюсь реализовать мультипликационную сагу, но по какой-то причине она перестала работать со мной, и я не знаю почему.

Вот мой полный код:

// store / sagas / sagas / auth.js

import { delay } from 'redux-saga';
import { put, call } from 'redux-saga/effects';

// When the client enter input on email / password textboxes on auth form.
export function* sagaFunction1(action) {
       yield call(actions.SomeAction1, { 'testSeting' );
}

// store / sagas / watchers / auth.js

import { takeEvery, all } from 'redux-saga/effects';
import * as actionTypes from '../../actions/actionTypes';
import * as sagas from '../sagas/auth';

export function* watchAuthSaga() {
    yield all([
        takeEvery(actionTypes.SAGA_FUNCTION1, sagas.sagaFunction1)
}

// store / sagas / rootSaga.js

import { all, fork } from 'redux-saga/effects';
import * as watchers from './rootWatchers';

const sagasList = [
    ...watchers
];

export default function* rootSaga() {
    yield all(sagasList.map(saga => fork(saga)));
}

// store / sagas / rootWatchers.js

import { watchAuthSaga } from './watchers/auth';
export default [watchAuthSaga];

// index.jsx

import React from 'react';
import ReactDOM from 'react-dom';
import './index.less';
import { BrowserRouter } from 'react-router-dom';
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { Provider } from 'react-redux';
import createSagaMiddleware from 'redux-saga';
import * as reducers from './store/reducers/reducers';
import rootSaga from './store/sagas/rootSaga';
import { getEnhancers } from './utils/coreUtils';
import App from './containers/App/App';
import registerServiceWorker from './registerServiceWorker';

// For redux development tools
const composeEnhancers = getEnhancers(compose);
const rootReducer = combineReducers({
    auth: reducers.authReducer
});

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

const app = (
    <Provider store={store}>
        <BrowserRouter>
            <App />
        </BrowserRouter>
    </Provider>
);
ReactDOM.render(app, document.getElementById('root'));
registerServiceWorker();

Что я делаю не так?

1 Ответ

0 голосов
/ 20 февраля 2019

// store / sagas / rootSaga.js

импорт * в качестве наблюдателей из './rootWatchers';

const sagasList = [... watchers];

Должно быть import watchers from './rootWatchers', потому что вы используете export default

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...