Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding parameter in anchor tag in react.js

I am trying to add a username in my anchor tag's href property. My Code is,

var Name = React.createClass({

    render: function() {
        return (
            <div>
                <a href="www.example.com/"+ { this.props.username} +"" className="post-title">{this.props.name}</a><br />
            </div>
        );
    }

});

But, I am getting an error saying undefined token + near that href property. I think this is due to I am trying to add it in render method. So, is there any other approach?

Thank you..

like image 772
Swapnil Bhikule Avatar asked Oct 21 '25 13:10

Swapnil Bhikule


1 Answers

Remove the +. It should be:

<a href={"www.example.com/" + this.props.username} ...
like image 66
Dane O'Connor Avatar answered Oct 23 '25 04:10

Dane O'Connor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!