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

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

@guewin

Description

@guewin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions