Show alert when url copied
ghstack-source-id: e8dba44d246d53f60a0858710cedf75c77c6c7e4 Pull Request resolved: https://github.com/facebook/react-forget/pull/2835
Lauren Tan committed
Apr 10, 2024 at 17:46 UTC
594f3352010fcd0dfdefcbcd07598e319aadaffb
1 file changed
+2
-2
compiler/apps/playground/components/Header.tsx
+2
-2
@@ -5,7 +5,6 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-
8
import { RefreshIcon, ShareIcon, TrashIcon } from "@heroicons/react/outline";
9
import { CheckIcon } from "@heroicons/react/solid";
10
import clsx from "clsx";
@@ -18,7 +17,7 @@ import { useStoreDispatch } from "./StoreContext";
17
export default function Header() {
18
const [showCheck, setShowCheck] = useState(false);
19
const dispatchStore = useStoreDispatch();
21
- const { closeSnackbar } = useSnackbar();
20
+ const { enqueueSnackbar, closeSnackbar } = useSnackbar();
21
22
const handleReset = () => {
23
if (confirm("Are you sure you want to reset the playground?")) {
@@ -43,6 +42,7 @@ export default function Header() {
42
43
const handleShare = () => {
44
navigator.clipboard.writeText(location.href).then(() => {
45
+ enqueueSnackbar("URL copied to clipboard");
46
setShowCheck(true);
47
// Show the check mark icon briefly after URL is copied
48
setTimeout(() => setShowCheck(false), 1000);