Skip to content

Instantly share code, notes, and snippets.

@Ginhing
Created June 24, 2016 03:22
Show Gist options
  • Save Ginhing/58305312a75f7f6d6165bb583ecc94ba to your computer and use it in GitHub Desktop.
Save Ginhing/58305312a75f7f6d6165bb583ecc94ba to your computer and use it in GitHub Desktop.
jsx condition
const _call = (result) => typeof result === 'function' ? result() : result;
const IF = (condition) => (result, otherResult = null) => _call(condition ? result : otherResult);
const FooComponent = () => (
<div>
{IF(true)(
<span>here is true and evaluated before the condition</span>,
_ => <p>here is false and will not be evaluated</p>
)}
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment