KnowledgeSeeker
KnowledgeSeeker

Reputation: 1088

Ngrx Store Redux of Angular won't work in Ionic 3 App

I want to implement ngrx store for my Ionic 3 App. They said that ngrx was inspired by redux. So I will try ngrx/store for a large app for a better state management of the whole app and make it centralize.

But whenever I try this line of code below to import this in my AppModules of my app.

// in the imports provider array 
StoreModule.forRoot({ counter: counterReducer }),

or this one below:

// Same implementation above
  StoreModule.provideStore({ counter: counterReducer })

I got an error that said below that

Uncaught TypeError: WEBPACK_IMPORTED_MODULE_0__angular_core.OpaqueToken is not a constructor

When I try to open the StoreModule import from @ngrx/store

I saw this import above that it can't find the OpaqueToken

import { OpaqueToken, ModuleWithProviders } from '@angular/core';

This is my ionic info below

Ionic:

ionic (Ionic CLI) : 4.0.0-rc.13 (/home/clifford/.npm-global/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.1.11

System:

NodeJS : v6.12.2 (/usr/local/bin/node) npm : 4.6.1 OS : Linux 4.13

Any thoughts on this?

Upvotes: 1

Views: 408

Answers (1)

KnowledgeSeeker
KnowledgeSeeker

Reputation: 1088

Finally solved the issue by doing

npm install @ngrx/store@5

But I have another issue error below when I import the StoreModule.forRoot

Unhandled Promise rejection: Cannot read property 'schedule' of undefined ; Zone: ; Task: Promise.then ;

You also need to install zone.js from the issue above.

in my case I used this npm i zone.js@^0.8.4 --save

Upvotes: 1

Related Questions