I am trying to import NGRX to build a new Angular application but i have this error in my terminale when i use ng serve:
ERROR in node_modules/@ngrx/store/src/reducer_creator.d.ts:32:99 - error TS1005: ',' expected.
32 export declare function on<State, Creators extends readonly ActionCreator[]>(...args: [...creators: Creators, reducer: OnReducer<State, Creators>]): ReducerTypes<State, Creators>; ~ node_modules/@ngrx/store/src/reducer_creator.d.ts:32:118 - error TS1005: ',' expected.
32 export declare function on<State, Creators extends readonly ActionCreator[]>(...args: [...creators: Creators, reducer: OnReducer<State, Creators>]): ReducerTypes<State, Creators>;
This Is my angular cli / node version / OS Angular CLI: 9.1.0 Node: 10.13.0 OS: darwin x64
Ngrx is a group of Angular libraries for reactive extensions. Ngrx/Store implements the Redux pattern using the well-known RxJS observables of Angular 2. It provides several advantages by simplifying your application state to plain objects, enforcing unidirectional data flow, and more.
NgRx implements the Flux-Pattern. At a high level, it helps you unify all events and derive a common state in your Angular app. With NgRx, you store a single state and use actions to express state changes. It is ideal for apps with many user interactions and multiple data sources.
Using NgRx store you can create your store, effects , reducers & actions in any angular app. On the other hand RxJS is used for mainly for consuming api data and creating shared services using subject etc.
NgRx implements the Flux-Pattern. At a high level, it helps you unify all events and derive a common state in your Angular app. With NgRx, you store a single state and use actions to express state changes. It is ideal for apps with many user interactions and multiple data sources.
NgRx uses the redux pattern within an Angular application. Setting it up can be quite difficult, so this is a guide following some of the best practices in setting up state management with NgRx. First, we need to install the necessary dependencies. As we’ll go for a solid base, we will use the store, effects and store-devtools.
The application state resides inside a Store. The Store acts like a container for the state in the ngrx/store module. In addition, Angular components inject the Store into their constructors to establish the communication channel. The Store exposes two methods used by the Angular components.
Here is the example project in the GitHub where you can clone and run it on your local machine. NGRX is a state management tool inspired by redux for the Angular Applications.
NgRx v11 expects TypeScript 4 to be used and Angular 11. https://ngrx.io/guide/migration/v11
Downgrade the @ngrx/store to 10.2.1 or lower version.
cmd: yarn add @ngrx/[email protected]
If you are using npm then
cmd: npm install @ngrx/[email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With