MCPcopy Create free account
hub / github.com/TanStack/query / render

Method render

examples/lit/default-query-function/src/post-list.ts:20–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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
65customElements.define('post-list', PostList)

Callers

nothing calls this directly

Calls 3

setPostIdMethod · 0.95
useQueryClientFunction · 0.90
getQueryDataMethod · 0.45

Tested by

no test coverage detected