Answers for "conditional jsx property"

4

conditional jsx property

render() {
  return (
    <a className="navbar-brand" {... url ? {href: url} : {}}>Logo</a>
  )
}
Posted by: Guest on February-28-2020
1

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} />
        );
    }
});
Posted by: Guest on July-06-2020

Code answers related to "conditional jsx property"

Code answers related to "Javascript"

Browse Popular Code Answers by Language