DEV Community


Discussion on: Reactive Props in Functional React

miketalbot profile image
Mike Talbot • Edited

Yeah that's nice. React writing JS from JSX and what that means is mind bending to start with!

Just for reference you could write your return as:

   return visible &&  <h1>Hello, world</h1> 

Presuming visible can only be true of false. If it could be "falsey" then:

   return !!visible &&  <h1>Hello, world</h1> 

Also of course you could make it a wrapper around children - and then have a generic one if you prefer it to the inline syntax (and still do your delays etc)

function Showable({show, children}) {
     return !!show && children