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

Make debugging selectors easy in development mode #470

Open
nvie opened this issue Sep 8, 2022 · 0 comments
Open

Make debugging selectors easy in development mode #470

nvie opened this issue Sep 8, 2022 · 0 comments
Assignees
Labels
feature request Feature requested by the community packages

Comments

@nvie
Copy link
Collaborator

nvie commented Sep 8, 2022

One of the easiest things to mess up performance is forgetting to add the shallow argument to your selector function if you're using a .map() or .filter() call in there, or when you want to select multiple subtrees.

To make debugging this easy, we could allow opting-in to a "StrictMode" like setup. When running in StrictMode, only during local development, each selector function would internally execute twice and is expected to be consistent (= both runs should compare equal using the provided isEqual helper). If not, it's tried with a shallow comparison to see if that would lead to the correct result. If so, we can emit a console error which hints at the developer that they may be forgetting the shallow arg.

I implemented a quick and dirty proof of concept for this feature, and I think it's promising. Of course, this needs to be polished before it's ready to ship, but I think people will love it to build performant apps.

@nvie nvie added the feature request Feature requested by the community label Sep 8, 2022
@nvie nvie self-assigned this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature requested by the community packages
Projects
None yet
Development

No branches or pull requests

2 participants