Skip to content

Commit

Permalink
type fixes for React 18
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Dec 6, 2024
1 parent 613c6ed commit 7452a5e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {useMutationObserver} from './useMutationObserver';
// Callback fires when the "hidden" attribute of a tabpanel changes
// See https://github.com/facebook/docusaurus/pull/7485
function useTabBecameVisibleCallback(
codeBlockRef: RefObject<HTMLPreElement | null>,
codeBlockRef: RefObject<HTMLPreElement>,
callback: () => void,
) {
const [hiddenTabElement, setHiddenTabElement] = useState<
Expand Down Expand Up @@ -53,7 +53,7 @@ function useTabBecameVisibleCallback(
}

export function useCodeWordWrap(): {
readonly codeBlockRef: RefObject<HTMLPreElement | null>;
readonly codeBlockRef: RefObject<HTMLPreElement>;
readonly isEnabled: boolean;
readonly isCodeScrollable: boolean;
readonly toggle: () => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-common/src/utils/reactUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function useEvent<T extends (...args: never[]) => unknown>(
* Gets `value` from the last render.
*/
export function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>(undefined);
const ref = useRef<T>();

useIsomorphicLayoutEffect(() => {
ref.current = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function useSkipToContent(): {
* so that keyboard navigators can instantly interact with the link and jump
* to content.
*/
containerRef: React.RefObject<HTMLDivElement | null>;
containerRef: React.RefObject<HTMLDivElement>;
/**
* Callback fired when the skip to content link has been clicked.
* It will programmatically focus the main content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function DocSearch({
})),
).current;

// @ts-expect-error: TODO fix lib issue after React 19, using JSX.Element
const resultsFooterComponent: DocSearchProps['resultsFooterComponent'] =
useMemo(
() =>
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/client/exports/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function Link(

const IOSupported = ExecutionEnvironment.canUseIntersectionObserver;

const ioRef = useRef<IntersectionObserver>(undefined);
const ioRef = useRef<IntersectionObserver>();

const handleRef = (el: HTMLAnchorElement | null) => {
innerRef.current = el;
Expand Down

0 comments on commit 7452a5e

Please sign in to comment.