Skip to content

Instantly share code, notes, and snippets.

@popcorn245
Created January 10, 2018 18:59
Show Gist options
  • Save popcorn245/a70f8b323947165d2f8c8a3ffc1d3d7d to your computer and use it in GitHub Desktop.
Save popcorn245/a70f8b323947165d2f8c8a3ffc1d3d7d to your computer and use it in GitHub Desktop.
Baking with StencilJS
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>
);
}
}
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