2017-10-21 1 views
0

발전기를 https://github.com/stylesuxx/generator-react-webpack-redux에서 사용하고 있습니다. 저장 파일에서 index.js에서감속기가 비어있는 동안 스토어에는 유효한 감속기가 없습니다.

import { combineReducers } from 'redux'; 

const reducers = {}; 
const combined = combineReducers(reducers); 
module.exports = combined; 

코드 : 개발은 내가 파일을 감소에 index.js에서 브라우저 콘솔에서 오류

warning.js:10 Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.

이 점을 제외하고 좋은 것입니다, 코드는 아래에 적혀있다 아래에 적혀있다 : 나는 현재의 개발에 REDUX를 사용하고 있지 않다

import { createStore } from 'redux'; 
import reducers from '../reducers'; 

function reduxStore(initialState) { 
    const store = createStore(reducers, initialState, 
    window.devToolsExtension && window.devToolsExtension()); 

    if (module.hot) { 
    // Enable Webpack hot module replacement for reducers 
    module.hot.accept('../reducers',() => { 
     // We need to require for hot reloading to work properly. 
     const nextReducer = require('../reducers'); // eslint-disable-line global-require 

     store.replaceReducer(nextReducer); 
    }); 
    } 

    return store; 
} 

export default reduxStore; 

하지만 난 GENER를 사용 미래 계획을위한 구성을위한 ator. 모든 아이디어를 어떤 경고를 유발하지 않고 const reducers = {}; 위의 코드와 같이 감속기를 비우는 방법을 알고 싶습니까?

답변

1

오류 제안과 같이 유효한 축소 기가 필요합니다. 당신은 보일러 또는

const reducers = { somename:() => {} }; 
const combined = combineReducers(reducers); 
module.exports = combined; 

을 유지하거나

module.exports =() => {}; 

이 반드시 유효한 감속기 기능을 반환하게됩니다 시도 할 경우 중 하나를 다음을 시도 할 수 있습니다. 당신이 redux를 사용하지 않으므로 이것은 문제가되지 않습니다.

0

왜 빈 개체 대신 함수를 만들려고합니까?

감속기 (기능) : 다음 상태 트리를 반환하는 감소 기능, 현재 상태 트리 및 처리 할 수있는 작업 주어진

는 REDUX 문서에 따르면이 기능해야한다. 당신이 하나를 가지고 combinereducers를 사용해야 할 경우 https://github.com/reactjs/redux/blob/master/docs/api/createStore.md

또한 모르겠어요.