react set property to component in if statement code example
Example 1: conditional jsx property
render() {
return (
<a className="navbar-brand" {... url ? {href: url} : {}}>Logo</a>
)
}
Example 2: How do I conditionally add attributes to React components?
var InputComponent = React.createClass({
render: function() {
var required = true;
var disabled = false;
return (
<input type="text" disabled={disabled} required={required} />
);
}
});