Skip to content

Instantly share code, notes, and snippets.

@designeng
Last active December 25, 2015 12:58
Show Gist options
  • Save designeng/45ea544f6a968b1031f2 to your computer and use it in GitHub Desktop.
Save designeng/45ea544f6a968b1031f2 to your computer and use it in GitHub Desktop.
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'));
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>
)
}
}
@designeng
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment