Skip to content

Comment on Create a character voting app using React, Node.js, MongoDB and Socket.ioparent

Comments

Here's how I would inline it, and I encourage people to do it this way. Intermediate variable is not necessary. Ternary is not necessary since false evaluates to null in jsx.

  render() {
   return (
     <div className='card'>
       {this.props.delta > 0 &&
         <strong className={this.props.delta > 0 ? 'text-success' : 'text-danger'}>
           {this.props.delta}
         </strong>
       }
       {this.props.title}
     </div>
   );
  }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.