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

great idea for the warning! #11

Open
gcloeval opened this issue Mar 24, 2019 · 2 comments
Open

great idea for the warning! #11

gcloeval opened this issue Mar 24, 2019 · 2 comments

Comments

@gcloeval
Copy link

This few lines here:

if (process.env.NODE_ENV !== "production") {
                const check = mapStateRef.current(state);
                if (!is(check, res)) {
                    console.warn(
                        "useMapState returns new identity on every run. This causes the component to render on every Redux state change. Consider use using useSelect().",
                        res,
                    );
                }
            }

this is so so excellent. You have saved me so much time. It cought every single place I mistankely was returning new identities and/or in general misconfiguring stuff. I know you are sort of using this as a prototyping for official redux hooks, so I just want to encourage you that this sort of warning is also included there.

@esamattis
Copy link
Owner

Thanks! Appreciate the feedback. Need to add this for useSelect too.

And add component stack traces once React.warn() ships: facebook/react#15170

@esamattis
Copy link
Owner

Oh, just be clear I'm not an author of react-redux. I've contributed to it few times but I have no direct influence on its API design.

But feedback like this can of course influence @markerikson and other authors indirectly.

The hooks api discussion is over here reduxjs/react-redux#1179

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