Last active
August 29, 2015 14:25
-
-
Save frank-weindel/44f4e627f90fb9cac817 to your computer and use it in GitHub Desktop.
This file contains 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
import { iff } from './globalUtils'; | |
function someRenderFunction() { | |
return ( | |
<div className="otsPropertyForm"> | |
{iff(showTeamList, () => ( | |
<FormSection> | |
<FormHeading>Select a Team:</FormHeading> | |
<ListBox items={teamItems} value={teamId} onChange={this._onTeamListChange} /> | |
</FormSection> | |
))} | |
{iff(showPlayList, () => ( | |
<FormSection> | |
<FormHeading>Select a Play:</FormHeading> | |
<ListBox items={playList} value={playId} onChange={this._onPlayListChange} height={300} /> | |
</FormSection> | |
))} | |
<FormSection> | |
<FormHeading>Select a Theme:</FormHeading> | |
<ListBox items={themeItems} value={dark} onChange={this._onThemeListChange} /> | |
</FormSection> | |
</div> | |
); | |
} |
This file contains 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
/** | |
* Calls the callback and returns its result if the expression is truthy | |
* | |
* @param {string} expression | |
* @param {Function} callback | |
* @return {variant} Value of callback() if expression is true. Otherwise 'undefined' | |
*/ | |
export function iff(expression, callback) { | |
if (expression) { | |
return callback(); | |
} | |
return void 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment