trufflesuite / drizzle

Reactive Ethereum dapp UI suite
907 stars 238 forks source link

Mismatching attribute name of generateStore-Interface and its implementation #138

Open Rackor opened 2 years ago

Rackor commented 2 years ago

Issue: In generateStore.d.ts https://github.com/trufflesuite/drizzle/blob/develop/packages/store/types/generateStore.d.ts the attribute for reducers has the name reducers

export interface IStoreConfig {
  [key: string]: any;
  drizzleOptions: IDrizzleOptions;
  reducers?: any;
  appSagas?: any[];
  appMiddlewares?: any[];
  disableReduxDevTools?: boolean;
}

where as the implementation in generateStore.js https://github.com/trufflesuite/drizzle/blob/develop/packages/store/src/generateStore.js uses for the same attribute the name appReducers. Therefore, a user relying on the interface attribute name and using it for setting the reducer variable, will cause in the reducers being not applied to the store. Also the attribute name in the documentation is wrong.

/**
 * Generate the redux store by combining drizzleOptions, application reducers,
 * middleware and initial app state.
 *
 * @param {object} config - The configuration object
 * @param {object} config.drizzleOptions - drizzle configuration object
 * @param {object} config.reducers={} - application level reducers to include in drizzle's redux store
 * @param {object[]} config.appSagas=[] - application sagas to be managed by drizzle's saga middleware
 * @param {object[]} config.appMiddlewares=[] - application middlewares to be managed by drizzle's saga middleware
 * @param {boolean} config.disableReduxDevTools=false - disable redux devtools hook
 * @returns {object} Redux store
 *
 */
export function generateStore ({
  drizzleOptions,
  appReducers = {},
  appSagas = [],
  appMiddlewares = [],
  disableReduxDevTools = false,
  ...options
}) {...}

Solution: Rename interface attribute to match implementation signature. reducers -> appReducers