mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user