Skip to content

Instantly share code, notes, and snippets.

@darrenjennings
Last active January 12, 2018 00:56
Show Gist options
  • Save darrenjennings/ca3e75aa18c3cdb9a221126fe33eb2b3 to your computer and use it in GitHub Desktop.
Save darrenjennings/ca3e75aa18c3cdb9a221126fe33eb2b3 to your computer and use it in GitHub Desktop.
Vue Render Prop - Child
const Mouse = {
name: "Mouse",
props: {
render: {
type: Function,
required: true
}
},
data() {
return {
x: 0,
y: 0
};
},
methods: {
handleMouseMove(event) {
this.x = event.clientX;
this.y = event.clientY;
}
},
render(h) {
return (
<div style={{ height: "100%" }} onMousemove={this.handleMouseMove}>
{this.$props.render(this)}
</div>
);
}
};
export default Mouse;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment