Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

The handleDelete and handleSubmit callbacks in the FeedbackComments component included comments in their dependency arrays, causing unnecessary re-creations on every state change.

Changes

  • Updated both callbacks to use functional update pattern: setComments(prevComments => ...) instead of setComments(comments => ...)
  • Removed comments from dependency arrays of handleDelete and handleSubmit

Example

// Before
const handleDelete = useCallback(
  async (commentId: number) => {
    setComments(comments.filter(c => c.id !== commentId));
  },
  [comments, createSuccessNotice, createErrorNotice]
);

// After
const handleDelete = useCallback(
  async (commentId: number) => {
    setComments(prevComments => prevComments.filter(c => c.id !== commentId));
  },
  [createSuccessNotice, createErrorNotice]
);

This prevents callback recreation on every comments state 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.

Copilot AI changed the title [WIP] Update feedback notes support in Forms based on review Optimize React callbacks with functional state updates Jan 2, 2026
Copilot AI requested a review from enejb January 2, 2026 18:52
@enejb enejb force-pushed the add/feedback-commnet-support branch 2 times, most recently from ff3d23b to 2b24fdf Compare January 6, 2026 19:22
Base automatically changed from add/feedback-commnet-support to trunk January 7, 2026 19:45
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

## Testing instructions:

* Go to '..'
*

🔴 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:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form [Package] Forms [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants