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

Method render

examples/lit/basic-graphql-request/src/post-list.ts:17–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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