Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save travisrcory/12778a7574d3bd28aa125605bedc848e to your computer and use it in GitHub Desktop.
Save travisrcory/12778a7574d3bd28aa125605bedc848e to your computer and use it in GitHub Desktop.
// Parent
{namespace Parent}
{template .render}
{param title: string}
{param _customEventListener: any}
{call ChildA.render}
{param events: [
'customEvent': $_customEventListener
]}
{param ref: 'childA'}
{/call}
{/template}
// Parent JS
class Parent extends Component {
myFunction() {
console.log(this.refs) // return object containing 'childA'
this.refs['childA'].functionToCall();
}
_customEventListener({someData}) {
// called when child emits it
console.log({someData}); // data passed up
}
}
// ChildA
{namespace ChildA}
{template .render}
{param title: string}
{/template}
// ChildA JS
class ChildA extends Component {
myFunction() {
this.emit('customEvent', {someData});
}
_customEventListener() {
// called when child emits it
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment