The Component has the capability to copy
any value like (Element, String, Number)
A minimal Demo Link
Value | Used as a | Description |
---|---|---|
CopyToClipboard | ✅ Component | Can be used as Component |
copyToClipboard | ✅ Service | Can be used as Service |
// Default import will return a Component
import CopyToClipboard from 'fe-pilot/CopyToClipboard';
<CopyToClipboard elementToBeCopy={`<div>Element to be Copy<div>`} />
import { CopyToClipboard, copyToClipboard } from 'fe-pilot/CopyToClipboard';
// Used as a Component
<CopyToClipboard elementToBeCopy={`<div>Element to be Copy<div>`} />
// Used as a Service
copyToClipboard({ elementToBeCopy={`Element to be Copy`} });
import { CopyToClipboard } from 'fe-pilot/CopyToClipboard';
const successCb = (response) => {
console.log("success response:", response);
}
const failureCb = (response) => {
console.log("failure response:", response);
}
return (
<CopyToClipboard
successCb={successCb}
failureCb={failureCb}
elementToBeCopy={`A string text To Copy`}
>
Pass clickable element (button, anchor, string, icon etc)
</CopyToClipboard>
);
Props | Type | Description | Response |
---|---|---|---|
successCb | Function | It will be called on success |
{ data: "Can be array/object/string/number", msgType: "SUCCESSFUL", msg: "A success msg", status: "SUCCESS" } |
loadingCb | Function | It will be called before success/failure. |
{ msgType: "LOADING", msg: "LOADING...", status: "LOADING" } |
failureCb | Function | It will be called on failure |
{ msgType: "ERROR", msg: "A failed msg", status: "FAILURE" } |
Props | Type | Description | Default Values |
showForever | Boolean | To hide/remove unsupported feature, make it false. | Default value is true |
elementToBeCopy* | Element | Pass the text/element/number to be copy | --- |