angular-redux / store

Angular 2+ bindings for Redux
MIT License
1.34k stars 205 forks source link

Error while starting my application with devTools #538

Closed jbprat closed 5 years ago

jbprat commented 5 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

MacOS 10.13.6 NodeJS Version: 8.11.2 Typescript Version: 2.7.2 Angular Version: 6.1.0 @angular-redux/store version: 9.0 @angular/cli version: 1.7.3

Expected Behaviour:

DevTools should start when I'm launching my application. Here is my StoreModule code:

export class StoreModule {
  constructor(
    public store: NgRedux<AppState>,
    private devTools: DevToolsExtension
  ) {
    // Activate the devTools in development mode
    let enhancers = [];    // ... add whatever other enhancers you want.

    console.log('devtools', !environment.production, environment)
    // You probably only want to expose this tool in devMode.
    if (!environment.production && devTools.isEnabled()) {
      enhancers = [ ...enhancers, devTools.enhancer() ];
    }

    // Tell Redux about our reducers and epics.
    store.configureStore(
      rootReducer,
      {},
      enhancers
    );
  }
}

Actual Behaviour:

While starting my application, I receive this error:

TypeError: "t.apply is not a function"
persistStatehttp://localhost:4300/:1:50056instrumenthttp://localhost:4300/:1:39514Bhttp://localhost:4300/:1:26967applyMiddlewarehttp://localhost:4300/vendor.js:150366:19configureStorehttp://localhost:4300/vendor.js:443:28StoreModulehttp://localhost:4300/main.js:2169:9_createClasshttp://localhost:4300/vendor.js:63919:20_createProviderInstancehttp://localhost:4300/vendor.js:63889:26initNgModulehttp://localhost:4300/vendor.js:63822:32NgModuleRef_http://localhost:4300/vendor.js:64548:9createNgModuleRefhttp://localhost:4300/vendor.js:64537:12debugCreateNgModuleRefhttp://localhost:4300/vendor.js:66362:12createhttp://localhost:4300/vendor.js:67079:16bootstrapModuleFactoryhttp://localhost:4300/vendor.js:59809:29invokehttp://localhost:4300/polyfills.js:2710:17onInvokehttp://localhost:4300/vendor.js:59320:24invokehttp://localhost:4300/polyfills.js:2709:17runhttp://localhost:4300/polyfills.js:2460:24runhttp://localhost:4300/vendor.js:59234:16bootstrapModuleFactoryhttp://localhost:4300/vendor.js:59807:16bootstrapModulehttp://localhost:4300/vendor.js:59849:53invokehttp://localhost:4300/polyfills.js:2710:17runhttp://localhost:4300/polyfills.js:2460:24scheduleResolveOrRejecthttp://localhost:4300/polyfills.js:3194:29invokeTaskhttp://localhost:4300/polyfills.js:2743:17runTaskhttp://localhost:4300/polyfills.js:2510:28drainMicroTaskQueuehttp://localhost:4300/polyfills.js:2917:25 main.ts:13:16

Additional Notes:

(optional)

jbprat commented 5 years ago

It was my mistake, I forgot to add an empty value to the third argument in configureStore, like this:

    store.configureStore(
      rootReducer,
      {},
      [],
      devTools.isEnabled() ? [devTools.enhancer()] : []
    );