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

<Portal /> w/ typescript is broken for demo #853

Open
Chubzorz opened this issue Aug 17, 2020 · 0 comments
Open

<Portal /> w/ typescript is broken for demo #853

Chubzorz opened this issue Aug 17, 2020 · 0 comments

Comments

@Chubzorz
Copy link

When rendering something simple similar to the demo using typescript (.tsx file):

1.   const NewComponent: React.FC = () => {
2.   const subheadingRef = useRef<HTMLElement>(null);
3.   const isOpen = false; // Some selector or hook would normally go here
4.
5.   return (
6.     <div>
7.        <h1>Heading</h1>
8.        <h3 ref={subheadingRef} />
9.        <Portal container={subheadingRef}>
10.        {isOpen && <>Subheading</>}
11.      </Portal>
12.    </div>
13.   );
14.  };

An error on line 9 appears:
Type 'false | Element' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>'. Type 'false' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>'.

It seems that the typing for the <Portal /> children differs from the documentation and the corresponding .d.ts declarations exported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant