Show alert when url copied

ghstack-source-id: e8dba44d246d53f60a0858710cedf75c77c6c7e4
Pull Request resolved: https://github.com/facebook/react-forget/pull/2835
This commit is contained in:
Lauren Tan
2024-04-10 17:46:34 -04:00
parent 2f66d37cfd
commit 594f335201
@@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
import { RefreshIcon, ShareIcon, TrashIcon } from "@heroicons/react/outline";
import { CheckIcon } from "@heroicons/react/solid";
import clsx from "clsx";
@@ -18,7 +17,7 @@ import { useStoreDispatch } from "./StoreContext";
export default function Header() {
const [showCheck, setShowCheck] = useState(false);
const dispatchStore = useStoreDispatch();
const { closeSnackbar } = useSnackbar();
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const handleReset = () => {
if (confirm("Are you sure you want to reset the playground?")) {
@@ -43,6 +42,7 @@ export default function Header() {
const handleShare = () => {
navigator.clipboard.writeText(location.href).then(() => {
enqueueSnackbar("URL copied to clipboard");
setShowCheck(true);
// Show the check mark icon briefly after URL is copied
setTimeout(() => setShowCheck(false), 1000);