Skip to content

Instantly share code, notes, and snippets.

@kenmori
Last active March 10, 2017 02:08
Show Gist options
  • Save kenmori/be568b5adbde522064f6eb7b77b656a2 to your computer and use it in GitHub Desktop.
Save kenmori/be568b5adbde522064f6eb7b77b656a2 to your computer and use it in GitHub Desktop.
else if statement in render function
let Button;
const isOpen = TfCommonUtils.isOpenSaleTime(new Date(), new Date(2017,2,18,0,0,0), new Date(2017,2,21,6,0,0));
if(!isOpen && isRightApplication) {
Button = <BtnA url={mailHref} />
} else if (!isOpen && !isRightApplication) {
Button = <BtnLink url={registerUrl} />
} else {
Button = <noscript />
}
// ~~~~~
return (
{Button}
)
///↓↓↓↓↓↓↓
return ({
!isOpen && isRightApplication ? <BtnA url={mailHref} />
:!isOpen && !isRightApplication ? <BtnLink url={registerUrl} />
: <noscript />
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment