// This Javascript <a> tag generates correctly React.createElement('a', {href:"mailto:"+this.props.email}, this.props.email)
However, I'm struggling to recreate it in JSX
<a href="mailto: {this.props.email}">{this.props.email}</a> // => <a href="mailto: {this.props.email}"></a>
The href tag thinks the {this.props.email}
is a string instead of dynamically inputting the value of {this.props.email}
. Any ideas on where I went amiss?
It is returning a string because you are assigning it to a string.
You'll want to set it to a dynamic property, that includes a the string at the beginning of it
<a href={"mailto:" + this.props.email}>email</a>
A slightly more ES6 way to do what Patrick is suggesting would be to use a template literal:
<a href={`mailto:${this.props.email}`}>email</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With