Created
June 24, 2016 03:22
-
-
Save Ginhing/58305312a75f7f6d6165bb583ecc94ba to your computer and use it in GitHub Desktop.
jsx condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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