Use clipboard imperative usage #7761
Open
+64
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #7754
📝 Description
Added possibility to call
copy
fromuseClipboard
imperatively.⛳️ Current behavior (updates)
To pass in a value that is obtained imperatively, e.g.
prompt
or value from a global object, you would need to either rely onuseEffect
and violate chains of computations or in SSR do a two-pass render to get access to the global object.🚀 New behavior
By calling the
useClipboard
withoutvalue
arguments, i.e. no arguments on onlyoptionsOrTimeout
argument you are able to pass in value toonCopy
callback.💣 Is this a breaking change (Yes/No): No
📝 Additional Information
I will link docs PR here as well once I create it.
Hey @segunadebayo! Here is the PR. Please checkout other
feat
commits as I had multiple ideas on how to solve the DX. I find this the best, but I would like to hear your opinion on this one.