packages/rrc-loader-helper/src/reducer-decorate.js
function generatedReducer(state = fn.defaultState, action) {
      const builtinState = builtinReducer(state, action, page);
      if (builtinState) return builtinState;
      if (Object.hasOwnProperty.call(fn, action.type) && typeof fn[action.type] === 'function') {
        return produce(state, (draft) => {
          try {
            return fn[action.type](draft, action);
          } catch (e) {
            if (process.env.NODE_ENV !== 'production') {
              throw e;
            }
            console.error('It"s called by rrc-loader-helper:' + e);
            sendError(e);
            return state;
          }
        });
      }
      return state;
    }
function generatedReducer(state = fn.defaultState, action) {
      const builtinState = builtinReducer(state, action, page);
      if (builtinState) return builtinState;
      if (Object.hasOwnProperty.call(fn, action.type) && typeof fn[action.type] === 'function') {
        return produce(state, (draft) => {
          try {
            return fn[action.type](draft, action);
          } catch (e) {
            if (process.env.NODE_ENV !== 'production') {
              throw e;
            }
            console.error('It"s called by rrc-loader-helper:' + e);
            sendError(e);
            return state;
          }
        });
      }
      return state;
    }
function generatedReducer ( state = fn . defaultState , action ) { const builtinState = builtinReducer ( state , action , page ) ; if ( builtinState ) return builtinState ; if ( Object . hasOwnProperty . call ( fn , action . type ) && typeof fn [ action . type ] === 'function' ) { return produce ( state , ( draft ) => { try { return fn [ action . type ] ( draft , action ) ; } catch ( e ) { if ( process . env . NODE_ENV !== 'production' ) { throw e ; } console . error ( 'It"s called by rrc-loader-helper:' + e ) ; sendError ( e ) ; return state ; } } ) ; } return state ; }
reducer 为对象的时候包装为immer处理方式
对象内 defaultState 为必须属性
reducer 为对象的时候包装为immer处理方式 对象内 defaultState 为必须属性