Skip to content
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

docs: improve useCopyToClipboard demo #560

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

luckrnx09
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Mar 27, 2024

🦋 Changeset detected

Latest commit: 27f5632

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
usehooks-ts Patch
eslint-config-custom Patch
www Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.then(() => {
console.log('Copied!', { text })
})
.catch(error => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The copy method never throws a rejected Promise.
We should let the user determine if the copy was successful by the resolved value.

@luckrnx09 luckrnx09 marked this pull request as ready for review March 27, 2024 10:13
@luckrnx09 luckrnx09 marked this pull request as draft March 27, 2024 12:47
@luckrnx09 luckrnx09 force-pushed the improve-useCopyToClipboard-demo branch from 0ac96cb to a18f1e4 Compare March 27, 2024 13:46
@luckrnx09 luckrnx09 marked this pull request as ready for review March 27, 2024 14:21
@juliencrn
Copy link
Owner

juliencrn commented Apr 4, 2024

Oh good catch! You're right, currently, the copy function never throws a error. But maybe instead of updating the doc, we should fix the hook to make the copy function "throwable" instead of returning a boolean. This way, we do have not to update the eslint rule and the hook's API will be more natural for JS dev.
What do you think about?

@luckrnx09
Copy link
Contributor Author

luckrnx09 commented Apr 4, 2024

@juliencrn Agree with you!
In fact, I prefer to throw an error if copy to clipboard was failed.
Don't forget to tell the user if we do the breaking change. In particular, users who don't use TypeScript may not be aware that the return value of the copy function has changed from Promise<boolean> to Promise<void>.

@luckrnx09
Copy link
Contributor Author

Please feel free to close this PR

@juliencrn
Copy link
Owner

Thank you for the quick response.

I will keep this PR open until we update the hook as a reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants