Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dev and site support React 19 #432

Merged
merged 14 commits into from
Dec 31, 2024
Merged
2 changes: 1 addition & 1 deletion .dumi/components/SemanticPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
// ======================== Hover =========================
const containerRef = React.useRef<HTMLDivElement>(null);

const timerRef = React.useRef<ReturnType<typeof setTimeout>>();
const timerRef = React.useRef<ReturnType<typeof setTimeout>>(null);

const [positionMotion, setPositionMotion] = React.useState<boolean>(false);
const [hoverSemantic, setHoverSemantic] = React.useState<string | null>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const ComponentChangelog: React.FC<Readonly<React.PropsWithChildren>> = (props)
return (
<>
{isValidElement(children) &&
cloneElement(children as React.ReactElement, {
cloneElement(children as React.ReactElement<any>, {
onClick: () => setShow(true),
})}
<Drawer
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/common/PrevAndNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ const PrevAndNext: React.FC<{ rtl?: boolean }> = ({ rtl }) => {
return (
<section className={styles.prevNextNav}>
{prev &&
React.cloneElement(prev.label as ReactElement, {
React.cloneElement(prev.label as ReactElement<any>, {
className: classNames(styles.pageNav, styles.prevNav, prev.className),
})}
{next &&
React.cloneElement(next.label as ReactElement, {
React.cloneElement(next.label as ReactElement<any>, {
className: classNames(styles.pageNav, styles.nextNav, next.className),
})}
</section>
Expand Down
8 changes: 6 additions & 2 deletions .dumi/theme/layouts/DocLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DocLayout: React.FC = () => {
const location = useLocation();
const { pathname, search, hash } = location;
const [locale, lang] = useLocale(locales);
const timerRef = useRef<ReturnType<typeof setTimeout>>();
const timerRef = useRef<ReturnType<typeof setTimeout>>(null);
const { direction } = useContext(SiteContext);
const { loading } = useSiteData();

Expand All @@ -52,7 +52,11 @@ const DocLayout: React.FC = () => {
timerRef.current = setTimeout(() => {
nprogressHiddenStyle?.remove();
}, 0);
return () => clearTimeout(timerRef.current);
return () => {
if (timerRef.current) {
clearTimeout(timerRef.current);
}
};
}, []);

// handle hash change or visit page hash from Link component, and jump after async chunk loaded
Expand Down
2 changes: 2 additions & 0 deletions .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import type { ThemeName } from '../common/ThemeSwitch';
import type { SiteContextProps } from '../slots/SiteContext';
import SiteContext from '../slots/SiteContext';

import '@ant-design/v5-patch-for-react-19';

const ThemeSwitch = React.lazy(() => import('../common/ThemeSwitch'));

type Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];
Expand Down
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ exports[`renders components/attachments/demo/files.tsx extend context correctly

exports[`renders components/attachments/demo/files.tsx extend context correctly 2`] = `
[
"Warning: Invalid DOM property \`%s\`. Did you mean \`%s\`?%s",
"Invalid DOM property \`%s\`. Did you mean \`%s\`?",
]
`;

Expand Down Expand Up @@ -2764,6 +2764,6 @@ exports[`renders components/attachments/demo/with-sender.tsx extend context corr

exports[`renders components/attachments/demo/with-sender.tsx extend context correctly 2`] = `
[
"Warning: \`NaN\` is an invalid value for the \`%s\` css style property.%s",
"\`NaN\` is an invalid value for the \`%s\` css style property.",
]
`;
Loading
Loading