Copy to clipboard react button component.
npm install react-copy-button> Copy to clipboard react button component. Demo: https://cham11ng.github.io/react-copy-button/



``bash`
yarn add react-copy-button
or
bun install react-copy-button
`jsx
// Functional Component with useRef hook.
import React from 'react';
import { useRef } from 'react';
import { useState } from 'react';
function App() {
const imageRef = useRef();
const url =
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/2000px-React-icon.svg.png';
return (
);
}
// Class Component
import * as React from 'react';
import CopyButton from 'react-copy-button';
const url =
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/2000px-React-icon.svg.png';
class Example extends React.Component {
constructor(props) {
super(props);
this.imageRef = React.createRef();
}
render() {
return (
);
}
}
`
`bashPackage
$ bun install
$ bun link
$ bun start
$ bun run build
$ cd example
$ bun install
$ bun start
$ bun run build
`
`
$ gh release create 0.2.1 --generate-notes --prerelease
$ bun publish
``
- execCommand here.
- Navigator.clipboard here.
MIT © cham11ng