Skip to content

SearchControl: Fix rest props mutation - #65740

Merged
tyxla merged 1 commit into
trunkfrom
fix/search-control-prop-mutation
Oct 1, 2024
Merged

tyxla merged 1 commit into
trunkfrom
fix/search-control-prop-mutation

Conversation

@tyxla

@tyxla tyxla commented Sep 30, 2024

Copy link
Copy Markdown
Member

What?

Currently, we're mutating a rest props object in the SearchControl component. This PR refactors to remove that mutation.

Why?

By mutating a rest props object, we could easily be mutating props themselves, and mutating props is not recommended as it could lead to unexpected consequences.

Also, this resolves an ESLint error when using React Compiler:

/gutenberg/packages/components/src/search-control/index.tsx
70:9  error  Mutating component props or hook arguments is not allowed. Consider using a local variable instead  react-compiler/react-compiler

See #61788 for more details.

How?

We're using an extra rest props call to avoid the mutation.

I believe no CHANGELOG is necessary in this PR.

Testing Instructions

Test SearchControl in Storybook and verify there are no regressions.

Testing Instructions for Keyboard

Same

Screenshots or screencast

None

@tyxla tyxla added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Sep 30, 2024
@tyxla
tyxla requested review from a team and Mamaduka September 30, 2024 12:15
@tyxla tyxla self-assigned this Sep 30, 2024
@tyxla
tyxla requested a review from ajitbohra as a code owner September 30, 2024 12:15
@github-actions

github-actions Bot commented Sep 30, 2024 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @tyxla!

@tyxla
tyxla merged commit aa2c25a into trunk Oct 1, 2024
@tyxla
tyxla deleted the fix/search-control-prop-mutation branch October 1, 2024 06:55
@github-actions github-actions Bot added this to the Gutenberg 19.4 milestone Oct 1, 2024
getdave pushed a commit that referenced this pull request Oct 1, 2024
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
huubl pushed a commit to huubl/gutenberg that referenced this pull request Oct 2, 2024
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
huubl added a commit to huubl/gutenberg that referenced this pull request Oct 2, 2024
draganescu pushed a commit that referenced this pull request Oct 2, 2024
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants