Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // src/components/app-home/app-home.tsx
  2.  
  3. import { Component, Element, Prop, State, Watch } from '@stencil/core'
  4. import { Store } from '@stencil/redux'
  5.  
  6. @Component({
  7. tag: 'app-home'
  8. })
  9. export class AppHome {
  10. @Element() el: HTMLElement
  11.  
  12. @Prop({ context: 'store' }) store: Store
  13. @State() books: Array<any>
  14.  
  15. @Watch('books')
  16. updateList() {
  17. this.el.querySelector('books-list').books = this.books
  18. }
  19.  
  20. componentDidLoad() {
  21. const { mapStateToProps } = this.store
  22.  
  23. mapStateToProps(this, state => {
  24. return {
  25. books: state.books.items
  26. }
  27. })
  28. }
  29.  
  30. render() {
  31. // ...
  32. }
  33. }
Add Comment
Please, Sign In to add comment