react-use icon indicating copy to clipboard operation
react-use copied to clipboard

useCopyToClipboard does not work for first time

Open devnomic opened this issue 4 years ago • 1 comments

What is the current behavior?

const [state, copyToClipboard] = useCopyToClipboard();

function handleClick() {
 copyToClipboard('hello world')
}

calling copyToClipboard changed the state, but it doesn't really change the actual clipboard When i paste the clipboard (cmd+v) it shows previous text, not hello world. After i call copyToClipboard again then it works. so it's kinda lag.

What is the expected behavior?

Works like normal copy to clipboard even for the first time. Right now i'm using copy to clipboard from usehooks-ts package. it works as expected.

import { useCopyToClipboard } from 'usehooks-ts';

A little about versions:

  • OS: Macos
  • Browser (vendor and version): Chrome
  • React: ^17.0.2
  • react-use: ^17.3.2
  • Did this worked in the previous package version? Don't know

devnomic avatar Mar 24 '22 03:03 devnomic

I have the same issue

issam-seghir avatar May 06 '24 14:05 issam-seghir