mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-17 20:49:24 +00:00
chore: upgrade to react 19 beta and next 14 canary
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import { memo, useCallback } from "react";
|
||||
import equal from "react-fast-compare";
|
||||
|
||||
import * as icons from "@/components/icons";
|
||||
|
||||
import { Base, BaseProps } from "./base";
|
||||
@@ -9,19 +6,17 @@ export type CopyProps = Omit<BaseProps, "icon" | "labelText" | "onClick"> & {
|
||||
text: string;
|
||||
};
|
||||
|
||||
function RawButton({ text, iconOnly, ...props }: CopyProps) {
|
||||
const onClick: BaseProps["onClick"] = useCallback(() => {
|
||||
export function Copy({ text, iconOnly, ...props }: CopyProps) {
|
||||
const onClick: BaseProps["onClick"] = () => {
|
||||
navigator.clipboard.writeText(text).catch(e => {
|
||||
if (e instanceof Error) {
|
||||
// eslint-disable-next-line no-alert
|
||||
alert(e.message);
|
||||
}
|
||||
});
|
||||
}, [text]);
|
||||
};
|
||||
|
||||
return (
|
||||
<Base {...props} icon={<icons.Copy size={16} />} {...{ iconOnly, onClick }} labelText="Copy" />
|
||||
);
|
||||
}
|
||||
|
||||
export const Copy = memo(RawButton, equal);
|
||||
|
||||
Reference in New Issue
Block a user