In JSX how do I set a className as string + {prop}

You can use string concatenation

<a data-featherlight={'string' + this.props.data.imageUrl}>

or use Template strings new ES2015 feature

<a data-featherlight={ `string${this.props.data.imageUrl}` }>

You can also try it:

<a data-featherlight={'string1' + this.props.data.imageUrl + 'string2'}>

or

<a data-featherlight={ `string1 ${this.props.data.imageUrl} string2` }>

If you are using Link component then you can concatenation like this:

<Link to={`getting-started/${this.props.message}`}>
     <h1>Under {this.props.message}/-</h1>
</Link>

Tags:

Reactjs