From fc6e224bcaaa74d44dc15a215dcd2a8694d50a7a Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 4 Feb 2025 10:14:01 +0100 Subject: [PATCH] [NoSsr] Reduce bundle size (#1244) --- packages/react/src/unstable-no-ssr/NoSsr.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react/src/unstable-no-ssr/NoSsr.tsx b/packages/react/src/unstable-no-ssr/NoSsr.tsx index 4c8f5db4b5..621fe83009 100644 --- a/packages/react/src/unstable-no-ssr/NoSsr.tsx +++ b/packages/react/src/unstable-no-ssr/NoSsr.tsx @@ -33,8 +33,10 @@ function NoSsr(props: NoSsrProps): React.JSX.Element { } }, [defer]); - // We need the Fragment here to force react-docgen to recognise NoSsr as a component. - return {mountedState ? children : fallback}; + // TODO casting won't be needed at one point https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65135 + // We could replace React.JSX.Element with React.ReactNode. + // But first, we need to bump min typescript support to version to 5.1 and enough people to adopt the above change. + return (mountedState ? children : fallback) as React.JSX.Element; } NoSsr.propTypes /* remove-proptypes */ = {