Skip to content

Instantly share code, notes, and snippets.

@jmbejar
Created December 20, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmbejar/157278a02e80ad9f382dc72168651de6 to your computer and use it in GitHub Desktop.
Save jmbejar/157278a02e80ad9f382dc72168651de6 to your computer and use it in GitHub Desktop.
Code example 4 in "Unopinionated comparison of Glimmer and React" Raw
<button onclick={{action setRandomAnimal}}>
{{yield}}
</button>
function AnimalButton(props) {
...
return (
<button onClick={setRandomAnimal}>
{props.children}
</button>
);
}
<AnimalButton @onAnimalPicked={{action addAnimalToList}}>
Set Random Animal
</AnimalButton>
function RandomAnimal() {
return (
<AnimalButton onAnimalPicked={this.addAnimalToList}>
Set Random Animal
</AnimalButton>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment