[feat]: DataTable Columns (ColumnDef) doesn't support passing of any state/functions
sagar-jani opened this issue · 0 comments
sagar-jani commented
Feature description
I have actions in data-table - copy, I want to show different icon to user when user clicked on the action. However i can't define any state inside columns.
Here is what I want to do
const copyToClipboard = async () => {
try {
await navigator.clipboard.writeText(loan.accountno);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);
} catch (err) {
console.error('Failed to copy text: ', err);
}
};
<DropdownMenuItem className="cursor-pointer" onClick={copyToClipboard}>
{isCopied ? (
<CopyCheckIcon className="h-4 w-4" />
) : (
<CopyIcon className="h-4 w-4" />
)}
Copy
</DropdownMenuItem>
Affected component/components
No response
Additional Context
Additional details here...
Before submitting
- I've made research efforts and searched the documentation
- I've searched for existing issues and PRs