Created
December 14, 2016 21:31
-
-
Save jethrolarson/1c0927276651eecb08115a4c90fcae57 to your computer and use it in GitHub Desktop.
Bind all solutions
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 React, {createClass} from 'react'; | |
class MediaLibrary = createClass({ | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
}, | |
render() { | |
return (<Bar onFoo={this.foo} />); | |
} | |
} |
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 React, {Component} from 'react'; | |
import bindAll from 'util/class'; | |
@bindAll | |
class MediaLibrary extends Component { | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
} | |
render() { | |
return (<Bar onFoo={this.foo} />); | |
} | |
} |
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 React, {Component} from 'react'; | |
class MediaLibrary extends Component { | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
} | |
render() { | |
return (<Bar onFoo={() => this.foo()} />); | |
} | |
} |
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 React, {Component} from 'react'; | |
class MediaLibrary extends Component { | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
} | |
render() { | |
return (<Bar onFoo={this.foo.bind(this)} />); | |
} | |
} |
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 React, {Component} from 'react'; | |
class MediaLibrary extends Component { | |
constructor(){ | |
super() | |
this.foo = this.foo.bind(this); | |
} | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
} | |
render() { | |
return (<Bar onFoo={this.foo} />); | |
} | |
} |
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 React from 'react'; | |
import Component from 'util/reactExt'; | |
class MediaLibrary extends Component { | |
foo() { | |
this.setState({foo: !this.state.foo}) | |
} | |
render() { | |
return (<Bar onFoo={this.foo} />); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes: