Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import { Component, Prop, h, JSX, Watch} from '@stencil/core';
  2.  
  3. @Component({
  4. tag: 'my-complex-prop',
  5. styleUrl: 'complex-prop.css',
  6. shadow: true
  7. })
  8. export class MyComplexPropComponent {
  9.  
  10. @Prop({mutable: true}) values: Array<string> = [];
  11.  
  12. toUpper (items: Array<string>) {
  13. return items.map( i => i.toUpperCase());
  14. }
  15.  
  16. @Watch('values') //this will run everytime values are changed
  17. onValuesChange(newValue: any, oldValue: any) {
  18. //change to upper here
  19. }
  20.  
  21. componentWillLoad() { // this wi
  22. console.log('Will load', this.values);
  23. this.values = this.toUpper(this.values);
  24. }
  25.  
  26.  
  27. render() : JSX.Element {
  28. return (
  29. <div class="nice">
  30. {this.values.map((item) => {
  31. return <div class="item">
  32. <span>{item}</span>
  33. </div>
  34. })}
  35. </div>
  36. );
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement