Skip to content

[@types/react] ReactPortal extends ReactElement#28264

Merged
johnnyreilly merged 1 commit into
DefinitelyTyped:masterfrom
tenorok:reactportal-fix
Aug 26, 2018
Merged

[@types/react] ReactPortal extends ReactElement#28264
johnnyreilly merged 1 commit into
DefinitelyTyped:masterfrom
tenorok:reactportal-fix

Conversation

@tenorok

@tenorok tenorok commented Aug 21, 2018

Copy link
Copy Markdown
Contributor

Portals types works normal when used in method render() of Class-Component. But, it have breaks when used in Functional-Component:

function PortalComponent(props: { root: HTMLElement }) {
    return ReactDOM.createPortal(
        <div/>,
        props.root
    );
}

function MyComponent() {
    const root = document.getElementById('#foo');
    if (!root) {
        return null;
    }

    return (
        // JSX element type 'ReactPortal' is not a constructor function for JSX elements.
        // Property 'render' is missing in type 'ReactPortal'.
        <PortalComponent root={root}/>
    );
}

platform components viewer viewer tsx turbo 2018-08-21 15-49-12

Actually code is works fine.
Portal should extends from ReactElement similarly JSX.Element.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://reactjs.org/docs/portals.html
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

@tenorok tenorok requested a review from johnnyreilly as a code owner August 21, 2018 13:05
@tenorok tenorok changed the title [@types/react][@types/react-dom] ReactPortal extends ReactElement [@types/react] ReactPortal extends ReactElement Aug 21, 2018
@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Aug 21, 2018
@typescript-bot

typescript-bot commented Aug 21, 2018

Copy link
Copy Markdown
Contributor

@tenorok Thank you for submitting this PR!

🔔 @johnnyreilly @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @DovydasNavickas @onigoetz @theruther4d @guilhermehubner @ferdaber @jrakotoharisoa @pascaloliv @Hotell - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added Awaiting reviewer feedback Unmerged The author did not merge the PR when it was ready. labels Aug 21, 2018
@typescript-bot

Copy link
Copy Markdown
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@johnnyreilly johnnyreilly merged commit 3e39c3e into DefinitelyTyped:master Aug 26, 2018
@johnnyreilly

Copy link
Copy Markdown
Member

Thanks!

@tenorok tenorok deleted the reactportal-fix branch August 27, 2018 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts). Unmerged The author did not merge the PR when it was ready.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants