Last active
August 29, 2015 14:04
-
-
Save brandonbloom/56be8fcd4989f7396a1a 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
/** @jsx React.DOM */ | |
var Bubbler = React.createClass({ | |
render: function() { | |
return <input type="button" onClick={this.props.onFoo} value="Click me"/>; | |
} | |
}); | |
var Handler = React.createClass({ | |
onFoo: function() { | |
alert("handled!"); | |
}, | |
render: function() { | |
return <Bubbler onFoo={this.onFoo}/>; | |
} | |
}); | |
React.renderComponent(<Handler/>, document.body); |
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
/** @jsx React.DOM */ | |
var Bubbler = React.createClass({ | |
render: function() { | |
return <input type="button" onClick={this.props.onFoo} value="Click me"/>; | |
} | |
}); | |
var Handler = React.createClass({ | |
effects: { | |
foo: function() { | |
alert("handled!"); | |
} | |
}, | |
render: function() { | |
return <Bubbler onFoo={this.effects.foo}/>; | |
} | |
}); | |
React.renderComponent(<Handler/>, document.body); |
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
/** @jsx React.DOM */ | |
var Bubbler = React.createClass({ | |
render: function() { | |
return <input type="button" onClick={this.props.onFoo} value="Click me"/>; | |
} | |
}); | |
var Handler = React.createClass({ | |
handlers: function() { | |
return [ | |
[this.props.eff, function() { | |
alert("handled!"); | |
}] | |
]; | |
}, | |
render: function() { | |
return this.props.children; | |
} | |
}); | |
var Wrapper = React.createClass({ | |
effects: { | |
foo: newEffect() | |
}, | |
render: function() { | |
return <Handler eff={this.effects.foo}><Bubbler onFoo={this.effects.foo}/></Handler> | |
} | |
}); | |
React.renderComponent(<Wrapper/>, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsbin.com/vapay/4/edit
It's really matter of calling the
handleMouseMove
method and testing forthis.state.dragging
; it's probably less performent, but not that much I think (though I'm not sure). This could probably be microbenchmarked, oh well.