Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
safer
Browse files Browse the repository at this point in the history
oliviertassinari committed Dec 29, 2024

Verified

This commit was signed with the committer’s verified signature.
oliviertassinari Olivier Tassinari
1 parent 8869613 commit 07de69f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/react/src/unstable-no-ssr/NoSsr.tsx
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import { NoSsrProps } from './NoSsr.types';
*
* Documentation: [Base UI Unstable No Ssr](https://base-ui.com/react/components/unstable-no-ssr)
*/
function NoSsr(props: NoSsrProps): React.ReactNode {
function NoSsr(props: NoSsrProps): React.JSX.Element {
const { children, defer = false, fallback = null } = props;
const [mountedState, setMountedState] = React.useState(false);

@@ -33,7 +33,10 @@ function NoSsr(props: NoSsrProps): React.ReactNode {
}
}, [defer]);

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 */ = {

0 comments on commit 07de69f

Please sign in to comment.