Any issues with using mapStoreToState to replicate Reflux.connect named state properties?
See original GitHub issueSpecifically, we’re working with a codebase that still uses Reflux.connect in mixins to connect to stores. Reflux.connect had the requirement to provide a property to map the store to.
We’ve upgraded to the latest Reflux version and the old behavior is still supported. However, now that we’re using ES6 classes and can’t use mixins, all of the properties from the stores are just copied verbatim to the component state and doesn’t seem to provide an ability to map them to a specific property like before. This was causing some problems.
Yesterday I tried using this.mapStoreToState
in the constructor in the following manner to replicate the old behavior and it seems to be working on the surface. e.g.
this.mapStoreToState(userStore, (store) => this.state.users = store);
This isn’t how mapStoreToState seems to be meant for use according to the documentation, but it is working.
Are there any problems with this technique that I’m not aware of?
EDIT UPDATE
I read the docs over again and I feel like the following might be the actual right way to do what I’m intending. Feedback is appreaciated.
this.mapStoreToState(userStore, (store) => {users: store});
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@aziz So we ended up writing a helper function:
And its used like this in the class constructor:
I don’t really know what’s in your store, or where you’re trying to get that in your component. So I can’t really give you a verbatim solution. I can only explain how
mapStoreToState
works for you.