Last active
June 7, 2019 18:11
-
-
Save Tallyb/d34c308a54c4d3ed3d86eb6f7de61553 to your computer and use it in GitHub Desktop.
Event method component
This file contains 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 { Component, State, Event, Method, EventEmitter, h , JSX } from '@stencil/core'; | |
@Component({ | |
tag: 'my-event', | |
styleUrl: 'event.css' | |
}) | |
export class MyEvent { | |
@State() buttonFace: string = 'Click Me!'; | |
@State() clicked: boolean; | |
@Event() buttonClicked: EventEmitter<string>; | |
@Method() | |
async updateFace(value: string): Promise<string>{ | |
this.buttonFace = value; | |
return this.buttonFace.toUpperCase(); | |
} | |
onClicked(value: string) { | |
console.log('value is: ', value); | |
this.clicked = !this.clicked; | |
this.buttonClicked.emit('Yep!') | |
} | |
render(): JSX.Element { | |
return ( | |
<button onClick={()=>this.onClicked('ABCD')}> | |
{this.buttonFace} | |
</button> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment