Skip to content

Instantly share code, notes, and snippets.

@pragmaticlogic
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save pragmaticlogic/3be46b839c74c74cf31d to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticlogic/3be46b839c74c74cf31d to your computer and use it in GitHub Desktop.
render
var Main = React.createClass({
render() {
// nothing above here
// anonymous function is immediately invoked
return ((context, props, state) => {
//quarantine impure code
//....
//....
//event handler code
//onKeyDownHandler = ...
//onSearchClick = ...
//pure code
var displayUserName = R.ifElse(R.eq(null), x => '', R.identity)
var displayError = R.ifElse(R.eq(null), x => '', x => ' user not found.')
return <div className="container">
<div className="row">
<div className="input-field col s12 m8 offset-m2">
<input placeholder="Github username" id="search-text" type="text" className="validate" onKeyDown={onKeyDownHandler} ref="searchText" />
<label className="active" for="search-label">Search Github user</label>
</div>
</div>
<div className="row center-align">
{displayUserName(props.data)} {displayError(props.data)}
</div>
<div className="row center-align">
<a className="waves-effect waves-light btn" onClick={onSearchClick}>Search</a>
</div>
</div>
})(this, this.props, this.state)
//nothing below here
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment