Here is an example of a selector taken from the NgRx documentation:
import { createSelector } from '@ngrx/store';
export interface FeatureState {
counter: number;
}
export interface AppState {
feature: FeatureState;
}
export const selectFeature = (state: AppState) => state.feature;
export const selectFeatureCount = createSelector(
selectFeature,
(state: FeatureState) => state.counter
);
I am facing an issue where this code does not work for me unless I also include the key of the root state defined in app.module.ts. For example, if I have the following setup in app.module.ts:
StoreModule.forRoot({rootKey: reducer}),
In order to make my selector work, I have to modify it like this:
export const selectFeature = (state: AppState) => state.rootKey.feature;
However, doing this results in an error because it deviates from my original AppState interface.
What could be causing this issue? What am I doing wrong?