-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat!: use native copy method #1852
base: next
Are you sure you want to change the base?
Conversation
Preview is ready. |
Visual Tests Report is ready. |
0c4054d
to
8afb15d
Compare
cc4705e
to
d6bc68b
Compare
3ded266
to
6f1539a
Compare
const content = React.useMemo<React.ReactElement<React.HTMLAttributes<HTMLElement>>>( | ||
() => children(status), | ||
[children, status], | ||
); |
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's no benefit of useMemo at all, children as function typically inline in jsx, so every render is new instance
if (text === textRef.current) { | ||
handleCopy(text, result); | ||
|
||
content.props?.onClick?.(event); |
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.
Shouldn't we call this onClick
unconditionally?
/> | ||
</ReactCopyToClipboard> | ||
<CopyToClipboard text={copyText}> | ||
{() => ( |
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.
Let's support normal children type as well as it was in ReactCopyToClipboard
? I find it usefull, if I don't need status feedback
@@ -0,0 +1,7 @@ | |||
export function copyText(text: string) { |
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.
This file is not needed to be at the root utils, place it near the component please
Breaking changes:
options
ofcopy-to-clipboard
removed from propsFixes #658