diff options
Diffstat (limited to 'src/components')
3 files changed, 10 insertions, 13 deletions
diff --git a/src/components/atoms/links/social-link/social-link.test.tsx b/src/components/atoms/links/social-link/social-link.test.tsx index 9129c27..041e150 100644 --- a/src/components/atoms/links/social-link/social-link.test.tsx +++ b/src/components/atoms/links/social-link/social-link.test.tsx @@ -1,4 +1,4 @@ -import { describe, expect, it } from '@jest/globals'; +import { describe, expect, it, jest } from '@jest/globals'; import { render, screen as rtlScreen } from '@testing-library/react'; import { SocialLink } from './social-link'; diff --git a/src/components/organisms/forms/search-form/search-form.test.tsx b/src/components/organisms/forms/search-form/search-form.test.tsx index 56ba0d7..d1fdfa9 100644 --- a/src/components/organisms/forms/search-form/search-form.test.tsx +++ b/src/components/organisms/forms/search-form/search-form.test.tsx @@ -1,4 +1,4 @@ -import { describe, expect, it } from '@jest/globals'; +import { describe, expect, it, jest } from '@jest/globals'; import { userEvent } from '@testing-library/user-event'; import { render, screen as rtlScreen } from '../../../../../tests/utils'; import { SearchForm } from './search-form'; diff --git a/src/components/templates/page/page-layout.tsx b/src/components/templates/page/page-layout.tsx index 8ea0087..db71e07 100644 --- a/src/components/templates/page/page-layout.tsx +++ b/src/components/templates/page/page-layout.tsx @@ -4,14 +4,13 @@ import { type FC, type HTMLAttributes, type ReactNode, - useRef, useCallback, } from 'react'; import { useIntl } from 'react-intl'; import type { BreadcrumbList } from 'schema-dts'; import { sendComment } from '../../../services/graphql'; import type { SendCommentInput } from '../../../types'; -import { useHeadingsTree, useIsMounted } from '../../../utils/hooks'; +import { useHeadingsTree } from '../../../utils/hooks'; import { Heading, Sidebar } from '../../atoms'; import { PageFooter, @@ -137,9 +136,9 @@ export const PageLayout: FC<PageLayoutProps> = ({ id: 'eys2uX', }); - const bodyRef = useRef<HTMLDivElement>(null); - const isMounted = useIsMounted(bodyRef); - const headingsTree = useHeadingsTree(bodyRef, { fromLevel: 2 }); + const { ref: bodyRef, tree: headingsTree } = useHeadingsTree<HTMLDivElement>({ + fromLevel: 2, + }); const saveComment: CommentFormSubmit = useCallback( async (data) => { @@ -223,12 +222,10 @@ export const PageLayout: FC<PageLayoutProps> = ({ })} className={`${styles.sidebar} ${styles['sidebar--first']}`} > - {isMounted && bodyRef.current ? ( - <TocWidget - heading={<Heading level={3}>{tocTitle}</Heading>} - tree={headingsTree} - /> - ) : null} + <TocWidget + heading={<Heading level={3}>{tocTitle}</Heading>} + tree={headingsTree} + /> </Sidebar> ) : null} {typeof children === 'string' ? ( |
