Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store.select function not working as expected #1135

Closed
Memeplexx opened this issue Jun 16, 2018 · 1 comment
Closed

store.select function not working as expected #1135

Memeplexx opened this issue Jun 16, 2018 · 1 comment

Comments

@Memeplexx
Copy link

Minimal reproduction of the bug/regression with instructions:

After upgrading my NGRX store to the latest version, I have been trying to configure my store so that production builds do not fail (because of AOT requirements). I followed this example:
#306 (comment)

Having now done that, I am suddenly having issues selecting state from the store that is more than 1 level deep in the state tree.
For example:
this prints the complete state tree correctly
this.store.select(s => s).subscribe(s => console.log(s));
whereas this prints 'undefined'
this.store.select(s => s.branch1).subscribe(s => console.log(s));

Here is my example code:
https://stackblitz.com/edit/angular-fbmtou

Expected behavior:

I expect to select from the state tree more than 1 level deep

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

NGRX: 6.0.1
Angular: 6.0.0
Node: 8.10.0
Chrome
Windows 10

@timdeschryver
Copy link
Member

timdeschryver commented Jun 16, 2018

As you can see in the first print, the state looks lik this:

{
  app: {
    branch1: {…},
    branch2: {…},
  }
}

This is because of the getReducer function:

export function getReducers() {
  return {
    app: reducers,
  };
}

Where it should be:

export function getReducers() {
  return reducers;
}

Or you should select the branch as: s=> s.app.branch1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants