()
| 18 | } |
| 19 | |
| 20 | render() { |
| 21 | const queryClient = useQueryClient() |
| 22 | const { isPending, isError, isFetching, data, error } = this.posts() |
| 23 | |
| 24 | return html` |
| 25 | <div> |
| 26 | <h1>Posts</h1> |
| 27 | <div> |
| 28 | ${ |
| 29 | isPending |
| 30 | ? html`<div>Loading...</div>` |
| 31 | : isError |
| 32 | ? html`<span>Error: ${error.message}</span>` |
| 33 | : html` |
| 34 | <div> |
| 35 | ${data.map( |
| 36 | (post) => html` |
| 37 | <p> |
| 38 | <a |
| 39 | href="#${post.id}" |
| 40 | style=${styleMap( |
| 41 | queryClient.getQueryData([`/posts/${post.id}`]) |
| 42 | ? { fontWeight: 'bold', color: 'green' } |
| 43 | : {}, |
| 44 | )} |
| 45 | @click=${(event: Event) => { |
| 46 | event.preventDefault() |
| 47 | this.setPostId(post.id) |
| 48 | }} |
| 49 | > |
| 50 | ${post.title} |
| 51 | </a> |
| 52 | </p> |
| 53 | `, |
| 54 | )} |
| 55 | </div> |
| 56 | <div>${isFetching ? 'Background Updating...' : ' '}</div> |
| 57 | ` |
| 58 | } |
| 59 | </div> |
| 60 | </div> |
| 61 | ` |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | customElements.define('post-list', PostList) |
nothing calls this directly
no test coverage detected