DEV Community

Discussion on: How to Maximize Reusability For Your React Components

Collapse
 
jannikwempe profile image
Jannik Wempe

Very well explained article, thanks! Love it ☺

I'd prefer a little adjustment though:

// replace this
{renderHeader ? (
        renderHeader()
      ) : header !== null ? (
        <ListHeader>{header}</ListHeader>
      ) : null}

// with this
{renderHeader !== undefined ?
     renderHeader() : 
     <ListHeader>{header}</ListHeader>
}

That way you don't need the extra header={null} prop but just can pass renderHeader={() => null}. Otherwise you would allow to pass header={null} and a renderHeader function, which should not exist at the same time.