From 69574a1db207706aa5b39030039bd578f9b0b67a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 1 Mar 2022 12:23:49 +0100 Subject: refactor: import dynamically SearchForm and Settings components These components are only available after a click from the user, so using dynamic import should improve performances. --- src/components/Toolbar/Toolbar.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/components') diff --git a/src/components/Toolbar/Toolbar.tsx b/src/components/Toolbar/Toolbar.tsx index 7b28757..17f9ef9 100644 --- a/src/components/Toolbar/Toolbar.tsx +++ b/src/components/Toolbar/Toolbar.tsx @@ -1,10 +1,21 @@ import { ButtonToolbar } from '@components/Buttons'; import MainNav from '@components/MainNav/MainNav'; -import SearchForm from '@components/SearchForm/SearchForm'; -import Settings from '@components/Settings/Settings'; +import Spinner from '@components/Spinner/Spinner'; +import dynamic from 'next/dynamic'; import { RefObject, useCallback, useEffect, useRef, useState } from 'react'; import styles from './Toolbar.module.scss'; +const DynamicSearchForm = dynamic( + () => import('@components/SearchForm/SearchForm'), + { + loading: () => , + } +); + +const DynamicSettings = dynamic(() => import('@components/Settings/Settings'), { + loading: () => , +}); + const Toolbar = () => { const [isNavOpened, setIsNavOpened] = useState(false); const [isSearchOpened, setIsSearchOpened] = useState(false); @@ -129,7 +140,7 @@ const Toolbar = () => { setIsActivated={setIsSearchOpened} />
- +
{ className={settingsClasses} ref={settingsModalRef} > - + ); -- cgit v1.2.3