-
Notifications
You must be signed in to change notification settings - Fork 843
Optimize React callbacks with functional state updates #46437
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
base: trunk
Are you sure you want to change the base?
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: enejb <[email protected]>
ff3d23b to
2b24fdf
Compare
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so: 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
The
handleDeleteandhandleSubmitcallbacks in the FeedbackComments component includedcommentsin their dependency arrays, causing unnecessary re-creations on every state change.Changes
setComments(prevComments => ...)instead ofsetComments(comments => ...)commentsfrom dependency arrays ofhandleDeleteandhandleSubmitExample
This prevents callback recreation on every
commentsstate change while maintaining correct behavior.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.