From a6b0201f44a722f031d6aad654338a02ba2d6309 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Thu, 21 Oct 2021 04:10:49 -0300 Subject: [PATCH] Lazy load CameraScanner component --- src/Home.tsx | 3 ++- src/Title.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Home.tsx b/src/Home.tsx index 650c86c..04824ce 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -5,12 +5,13 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn"; import { faQrcode } from "@fortawesome/free-solid-svg-icons/faQrcode"; import Logo from "./Logo"; -import CameraScanner from "./search/CameraScanner"; import Timestamp from "./components/Timestamp"; import { RuntimeContext } from "./useRuntime"; import { useLatestBlock } from "./useLatestBlock"; import { blockURL } from "./url"; +const CameraScanner = React.lazy(() => import("./search/CameraScanner")); + const Home: React.FC = () => { const { provider } = useContext(RuntimeContext); const [search, setSearch] = useState(); diff --git a/src/Title.tsx b/src/Title.tsx index e4c5f47..e132443 100644 --- a/src/Title.tsx +++ b/src/Title.tsx @@ -4,10 +4,11 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faQrcode } from "@fortawesome/free-solid-svg-icons/faQrcode"; import useKeyboardShortcut from "use-keyboard-shortcut"; import PriceBox from "./PriceBox"; -import CameraScanner from "./search/CameraScanner"; import SourcifyMenu from "./SourcifyMenu"; import { RuntimeContext } from "./useRuntime"; +const CameraScanner = React.lazy(() => import("./search/CameraScanner")); + const Title: React.FC = () => { const { provider } = useContext(RuntimeContext); const [search, setSearch] = useState();