Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngrx import in angular application

Tags:

angular

ngrx

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

like image 657
michelemalagnini Avatar asked Feb 17 '21 08:02

michelemalagnini


People also ask

What is NgRx library in Angular?

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.

Why we use NgRx store in Angular?

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.

What is difference between NgRx and RxJS?

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.

What is ngrx in angular?

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.

How do I set up state management with ngrx?

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.

Where does the application state reside in angular?

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.

Can I run ngrx on my local machine?

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.


2 Answers

NgRx v11 expects TypeScript 4 to be used and Angular 11. https://ngrx.io/guide/migration/v11

like image 186
timdeschryver Avatar answered Nov 11 '22 19:11

timdeschryver


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]

like image 36
Muhammad Moazzam Avatar answered Nov 11 '22 19:11

Muhammad Moazzam