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

Named import alias used as a function's name #1083

Closed
quantizor opened this issue Oct 26, 2016 · 5 comments · Fixed by #1168
Closed

Named import alias used as a function's name #1083

quantizor opened this issue Oct 26, 2016 · 5 comments · Fixed by #1168

Comments

@quantizor
Copy link

quantizor commented Oct 26, 2016

For a sample component:

import React from 'react';
import {render, unmountComponentAtNode} from 'react-dom';

export default class Portal extends React.Component {
    static defaultProps = {
        destination: document.body,
    }

    id = 'foo'

    // the <div> that the children are rendered into
    $portal = null

    // the top-level child rendered into the $portal
    $passenger = null;

    componentWillMount() {
        this.$portal = document.createElement('div');
        this.props.destination.appendChild(this.$portal);

        this.renderPortalledContent();
    }

    renderPortalledContent() {
        const child = React.isValidElement(this.props.children) ? this.props.children : (<div>{this.props.children}</div>);

        this.$portal.id = this.id;

        render(child, this.$portal);
        this.$passenger = this.$portal.children[0];
    }

    componentDidUpdate() { this.renderPortalledContent(); }

    componentWillUnmount() {
        unmountComponentAtNode(this.$portal);
        this.props.destination.removeChild(this.$portal);
    }

    render() {
        return (<span />);
    }
}

I'm seeing the output I'm seeing this for the Portal.prototype.render entry:

{
        key: 'render',
        value: function reactDom.render() {
            return React__default.createElement('span', _extends({}, omitKeysFromSourceObject(this.props, UIPortal.internalKeys), { 'data-portal-id': this.props.portalId || this.id }));
        }
 }

Note the value: function reactDom.render() { part, which is invalid JS.

Seeing this in 0.36.3.

@Rich-Harris
Copy link
Contributor

Do you have a repro you can share? Thanks

@Rich-Harris
Copy link
Contributor

No need to worry about that repro – encountered the same bug myself (in Rollup's own codebase, embarrassingly enough!). Fix inbound

Rich-Harris added a commit that referenced this issue Dec 22, 2016
bind function expression ids to the child scope
@Rich-Harris
Copy link
Contributor

Fixed in 0.38

@quantizor
Copy link
Author

quantizor commented Dec 22, 2016 via email

@Rich-Harris
Copy link
Contributor

@yaycmyk no, I don't – maybe we'll set one up one day! Thanks, it means a lot

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

Successfully merging a pull request may close this issue.

2 participants