Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(site): updateuseClipboard to work better with effect logic#20183

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Parkreiner merged 7 commits intomainfrommes/clipboard-update
Oct 6, 2025

Conversation

Parkreiner
Copy link
Member

@ParkreinerParkreiner commentedOct 6, 2025
edited
Loading

No issue to track – spurred by#20129

Basically, theuseClipboard hook worked just fine up until now because we could always derive the clipboard text from within a render. There was never a case before where we would need to derive the text from outside React, and then sync it with both React and the browser. This PR updates the API to make that use case much more ergonomic and avoid risks of infinite renders

Changes made

  • UpdateduseClipboard API to require passing the text in via thecopyToClipboard function, rather than requiring that the text gets specified in render logic
  • Ensured that thecopyToClipboard function always stays stable across all React lifecycles
  • Updated all existing uses to use the new function signatures
  • Updated all tests and added new cases

@ParkreinerParkreiner self-assigned thisOct 6, 2025
};
}

functionrenderUseClipboard<TInputextendsUseClipboardInput>(inputs:TInput){
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I have no idea why I made this generic originally

Copy link
Member

@code-ashercode-asher left a comment

Choose a reason for hiding this comment

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

Amazing thank you! I tried it out on my PR as well and it works wonderfully.

* will dispatch an error message to the GlobalSnackbar
*/
onError?:(errorMessage:string)=>void;
clearErrorOnSuccess?:boolean;
Copy link
Member

Choose a reason for hiding this comment

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

I was going to say, as a gut reaction, I feel like I would expect this to clear the error on success by default, but actually it looks like we never useerror anywhere? Maybe we could even drop storing and exposing the error for now?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yeah, I can see that. I feel like we'lleventually need it, and the code is already set up to account for it in the tests, so I think merging it in now has the least friction. But I'll look into removing the error behavior in a bit

Copy link
MemberAuthor

@ParkreinerParkreinerOct 6, 2025
edited
Loading

Choose a reason for hiding this comment

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

For context, theclearErrorOnSuccess prop isn't "new", because it was already in the Registry codebase for a few months after I copied this file over there

@ParkreinerParkreiner merged commit156f985 intomainOct 6, 2025
31 checks passed
@ParkreinerParkreiner deleted the mes/clipboard-update branchOctober 6, 2025 19:41
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 6, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@code-ashercode-ashercode-asher approved these changes

@aslilacaslilacAwaiting requested review from aslilacaslilac is a code owner

Assignees

@ParkreinerParkreiner

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Parkreiner@code-asher

[8]ページ先頭

©2009-2025 Movatter.jp