Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Created February 11, 2019 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratbeard/a3c57d76d491a4f4f257208c5f71e2df to your computer and use it in GitHub Desktop.
Save ratbeard/a3c57d76d491a4f4f257208c5f71e2df to your computer and use it in GitHub Desktop.
export function Logo({ src }: {
src: string,
}) {
return ifPresent(src, (
<div className='web-activity-header-logo'>
<img src={src} className='web-activity-header-img' />
</div>
));
}
import React from 'react'
/**
* Renders the given markup if the given value is truthy.
* Else renders an empty fragment.
*
* @param value value to check, typically a string that could be undefined or * "".
* @param markup jsx markup to render if value is truthy.
*/
export function ifPresent(value: any, markup: JSX.Element) {
return value ? markup : <></>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment