sergey-t
10/1/2017 - 4:49 PM

conditional_statements

const isFunction = input => typeof input === 'function';

export default predicate => elemOrThunk =>
  predicate ? (isFunction(elemOrThunk) ? elemOrThunk() : elemOrThunk) : null;
canShowSecretData() { 
  const { dataIsReady, isAdmin, userHasPermissions } = this.props 
  return dataIsReady && (isAdmin || userHasPermissions)
}

<div> 
  {this.canShowSecretData() && <SecretData />} 
</div>