Skip to content

Cannot Resolve Stylename If not explicitly a String #72

Open
@shawnrice

Description

@shawnrice

Take the following code snippet:

render() {
    const appliedStyles = ['one', 'two'];
    appliedStyles.push(this.props.a ? 'style-a' : 'style-b');

    return (
        <div styleName={ appliedStyles.join( ' ' ) }>
            Hello
        </div>
    );
}

What you'll see is that we'll end up getting something like Unhandled rejection Error: Could not resolve the styleName 'style-a'.

However, if we change the code ever so slightly to

<div styleName={ `${ appliedStyles.join( ' ' ) }` }>

then it seems to work.

Is this a Babel constraint or a fixable bug? The pattern works with your non-babel version.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions