Skip to content

v0.14.3: Inside render's return, any comments placed above the first line cause various errors #5573

@sheminusminus

Description

@sheminusminus

Using v0.14.3, one comment placed on first line of render()'s return causes nothing to be rendered in browser. My code causing this:

    return (
        {/* class is a reserved word, so must ref this with className */}
        <div className="wrapper">
            <h1>React!</h1>
            {/* attributes defined in the ReactDom.render() function are referenced with { this.props.attribute } */}
            <h2>{ this.props.message }</h2>
            <Thingy name="Thingy1" content="Cat in the Hat" />
            <Thingy name="Thingy2" content="Bat in the Frat" />
            <Thingy name="Thingy3" content="Sat in the Vat" />
        </div>
    )

Two comments cause an unexpected token error. My code causing this:

    return (
        {/* react needs one parent for the component */}
        {/* class is a reserved word, so must reference this with className */}
        <div className="wrapper">
            <h1>React!</h1>
            {/* attributes defined in the ReactDom.render() function are referenced with { this.props.attribute } */}
            <h2>{ this.props.message }</h2>
            <Thingy name="Thingy1" content="Cat in the Hat" />
            <Thingy name="Thingy2" content="Bat in the Frat" />
            <Thingy name="Thingy3" content="Sat in the Vat" />
        </div>
    )

This causes no errors at all:

    return (
        <div className="wrapper">
        {/* react needs ONE parent container for the component */}
        {/* also, class is a reserved word in JSX, so must ref this with className */}
            <h1>React!</h1>
            {/* attributes defined in the ReactDom.render() function are referenced with { this.props.attribute } */}
            <h2>{ this.props.message }</h2>
            <Thingy name="Thingy1" content="Cat in the Hat" />
            <Thingy name="Thingy2" content="Bat in the Frat" />
            <Thingy name="Thingy3" content="Sat in the Vat" />
        </div>
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions