Skip to content

Stores not "composing"? #156

Closed
Closed
@levibotelho

Description

@levibotelho

I'm having a bit of a hard time understanding the example provided on the main page in regards to stores.

I have two stores defined, each of which consists of a single function that returns an object. When creating my redux instance, I do the following:

var stores = {
    authenticationStore: require("../stores/authentication-store"),
    signUpStore: require("../stores/sign-up-store")
};

var dispatcher = Redux.createDispatcher(
  Redux.composeStores(stores),
  function (getState) {
    return [promiseMiddleware(getState), thunkMiddleware(getState)];
  }
);

So far so good, as far as I can tell.

My problem is that in the select method on one of my components, I attempt to read the store values as follows

function selectSignUpFormProps(state) {
  // signUpStore returns an object containing signedUpUser and signUpError properties.
  return {
    user: state.signedUpUser,
    error: state.signUpError
  };
}

However instead of containing signedUpUser and signUpError properties as I would expect, state contains authenticationStore and signUpStore properties which contain the return values of their respective functions.

By looking at the demo on the main page of the repo, I was under the impression that the results of my store functions would be composed into a single state object, and not subdivided by store. Am I doing something incorrectly, or is my understanding of stores/state flawed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions