Best solution with react hooks, no need of external libraries for that
import React, { useState } from 'react';_x000D_
_x000D_
const MyComponent = () => {_x000D_
const [copySuccess, setCopySuccess] = useState('');_x000D_
_x000D_
// your function to copy here_x000D_
_x000D_
const copyToClipBoard = async copyMe => {_x000D_
try {_x000D_
await navigator.clipboard.writeText(copyMe);_x000D_
setCopySuccess('Copied!');_x000D_
} catch (err) {_x000D_
setCopySuccess('Failed to copy!');_x000D_
}_x000D_
};_x000D_
_x000D_
return (_x000D_
<div>_x000D_
<Button onClick={() => copyToClipBoard('some text to copy')}>_x000D_
Click here to copy_x000D_
</Button>_x000D_
// after copying see the message here_x000D_
{copySuccess}_x000D_
</div>_x000D_
)_x000D_
}
_x000D_
check here for further documentation about navigator.clip board , navigator.clipboard documentation navigotor.clipboard is supported by a huge number of browser look here supported browser