React renders multiple spans, only with the actual value. Any advice on how to fix this:
And if it matter, the name of the user isn't suppose to be in a span, but as innerHTML of ".chatUser"
The actual render method is short:
createShortUsername: function() {
// shortName is first two letter of first name.
var shortName = this.props.userName.split(" ")[0].slice(0, 2);
console.log(shortName);
return shortName;
},
render: function() {
return (
<div className="chatUser"> {this.createShortUsername()} </div>
);
}
Thanks!
As suggested by @ivarni, the extra spans were caused by white spaces!
To prevent this write your code without white spaces around the braced expressions.
<ReactElement>{noRoomForWhiteSpace}</ReactElement>
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