-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Data: Expose 'useSelect' warning to third-party consumers #67735
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: 0 B Total Size: 1.83 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. I like how this will push the devs to improve the perf of their code. We should have more hints like that.
Checking the code, I see preexisting checks like |
8154c46
to
062ecb8
Compare
Updated |
Flaky tests detected in cd53743. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12235884543
|
@@ -19,6 +19,15 @@ import { | |||
import _fontSize from '../font-size'; | |||
|
|||
const noop = () => {}; | |||
const EMPTY_ARRAY = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the check is helpful as it helps to promote best practices even in unit tests 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Mamaduka, this is super helpful 🙌 🚀
beforeAll( () => { | ||
// Do not run HOC in development mode; it will call `mapSelect` an extra time. | ||
globalThis.SCRIPT_DEBUG = false; | ||
} ); | ||
|
||
afterAll( () => { | ||
globalThis.SCRIPT_DEBUG = initialScriptDebug; | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need this more and more in the future, we might consider abstracting it into an opt-in global jest setup/teardown configuration. However, for just 3 instances, it will be an unnecessary abstraction.
I think a dev note would be helpful here so folks aren't surprised. I'll try do draft something before I forget 😄 |
What?
PR exposes the
useSelect
performance warning to third-party consumers. It would help them catch any possible issues while extending the block editor.The warning is only available when
globalThis.SCRIPT_DEBUG
is true:SCRIPT_DEBUG
constant inwp-config.php
.npm run dev
.The bundle size increase should be negligible.
Why?
Everyone benefits
Testing Instructions
Test plugin
Testing Instructions for Keyboard
Same.
Screenshots or screencast