Last active
December 25, 2015 12:58
-
-
Save designeng/45ea544f6a968b1031f2 to your computer and use it in GitHub Desktop.
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
| import React from 'react'; | |
| import { render } from 'react-dom'; | |
| import Interactive from './interactive' | |
| const activateCallback = () => { | |
| console.log("activateCallback invoked"); | |
| } | |
| export default class Application extends React.Component { | |
| render() { | |
| return ( | |
| <Interactive activate={activateCallback} /> | |
| ) | |
| } | |
| } | |
| render(<Application />, document.querySelector('#application')); |
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
| import React from 'react'; | |
| import callbackRegister from "react-callback-register" | |
| @callbackRegister | |
| export default class Interactive extends React.Component { | |
| @callbackRegister.on('mouseDown') | |
| activate(e) { | |
| this.props.activate(e) | |
| } | |
| render() { | |
| const {activate, ...other} = this.props; | |
| return ( | |
| <div {...other} {...this.callbacks}> | |
| Interactive | |
| </div> | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to https://github.com/unicorn-standard/react-callback-register