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

Does memoize-state handle situations in which mapStateToProps is a factory? #7

Closed
sebinsua opened this issue Mar 28, 2018 · 2 comments

Comments

@sebinsua
Copy link

sebinsua commented Mar 28, 2018

When I use this module in patch mode in my application I get runtime errors. Presumably this is because my mapStateToProps is not passing in the correct state.

I seemed to be able to fix this by no longer passing in a mapStateToPropsFactory into connect.

To quote the react-redux API:

Note: in advanced scenarios where you need more control over the rendering performance, mapStateToProps() can also return a function. In this case, that function will be used as mapStateToProps() for a particular component instance. This allows you to do per-instance memoization. You can refer to #279 and the tests it adds for more details. Most apps never need this.

Am I mistaken that this is not supported?

I created the issue here rather than on the other repository, because I have an application which has partial usage of reselect selectors in some places but there are some problems with how these were written. I was going to use check to find out what was broken, but also decided to try patch and it did not work out-of-the-box. I don't think it's as 'advanced' as the react-redux documentation says: when you are using reselect you create selector factories quite frequently...

Maybe you be handling the situations in which mapStateToProps is a factory of mapStateToProps functions here?

Edit: I also noticed that in check mode, I get a lot of warnings about object spreading, which presumably means this is only sometimes working?

Edit 2: There are a couple of times in which check isn't working presumably due to the factory problem, since the "result is not equal at [resultFunc,recomputations,resetRecomputations], while should be equal". Presume this is related to the main issue?

@sebinsua sebinsua changed the title Does memoize-state handle situations in which mapStateToProps was a factory? Does memoize-state handle situations in which mapStateToProps is a factory? Mar 28, 2018
@theKashey
Copy link
Owner

  1. This library uses mapStateToPropsFactory by itself, not checking if you are doing the same. Something to be fixed.

  2. Spreading "touches" all the keys, leveraging the ability to properly react only for important changes. (see Should detect whole state spreading memoize-state#5)

  3. Yep, it is related to the main issue.

@theKashey
Copy link
Owner

patch - support for mapStateToProps fabrics added into v1.3.0.
check - still not understanding this pattern, and may complain about.

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