Created
January 10, 2018 18:59
-
-
Save popcorn245/a70f8b323947165d2f8c8a3ffc1d3d7d to your computer and use it in GitHub Desktop.
Baking with StencilJS
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 } from '@stencil/core'; | |
@Component({ | |
tag: 'app-home', | |
styleUrl: 'app-home.scss' | |
}) | |
export class AppHome { | |
render() { | |
return ( | |
<div> | |
<the-oven ingredients={["milk", "eggs", "butter", "flour"]} /> | |
</div> | |
); | |
} | |
} |
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, Prop, State } from '@stencil/core'; | |
@Component({ | |
tag: 'the-oven', | |
styleUrl: 'the-oven.scss' | |
}) | |
export class TheOven { | |
@Prop() ingredients: any; | |
@State() ingredientList: any; | |
componentWillLoad() { | |
this.ingredientList = typeof this.ingredients === 'string' ? JSON.parse(this.ingredients) : this.ingredients; | |
} | |
render() { | |
return ( | |
<div> | |
{this.ingredientList ? this.ingredientList.map((ingredient) => | |
<a>{ingredient}</a> | |
) : null } | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment