Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

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

Open
Rackor opened this issue Apr 2, 2022 · 0 comments

Comments

@Rackor
Copy link

Rackor commented Apr 2, 2022

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant