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

Method render

examples/lit/auto-refetching/src/main.ts:60–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 }
59
60 render() {
61 const { status, data, error, isFetching } = this.todos()
62
63 if (status === 'pending') return html`<h1>Loading...</h1>`
64 if (status === 'error') return html`<span>Error: ${error.message}</span>`
65
66 return html`
67 <div>
68 <h1>Auto Refetch with refetchInterval set to ${this.intervalMs}ms</h1>
69 <p>
70 This example is best experienced on your own machine, where you can
71 open multiple tabs to the same localhost server and see your changes
72 propagate between the two.
73 </p>
74 <label>
75 Query Interval speed (ms):
76 <input
77 .value=${String(this.intervalMs)}
78 @input=${(event: Event) =>
79 (this.intervalMs = Number(
80 (event.currentTarget as HTMLInputElement).value,
81 ))}
82 type="number"
83 step="100"
84 />
85 <span
86 style="display: inline-block; margin-left: .5rem; width: 10px; height: 10px; background: ${
87 isFetching ? 'green' : 'transparent'
88 }; transition: ${
89 !isFetching ? 'all .3s ease' : 'none'
90 }; border-radius: 100%; transform: scale(2)"
91 ></span>
92 </label>
93 <h2>Todo List</h2>
94 <form @submit=${this.submitForm}>
95 <input
96 placeholder="enter something"
97 .value=${this.value}
98 @input=${(event: Event) =>
99 (this.value = (event.currentTarget as HTMLInputElement).value)}
100 />
101 </form>
102 <ul>
103 ${data.map((item) => html`<li>${item}</li>`)}
104 </ul>
105 <div>
106 <button type="button" @click=${() => this.clearMutation.mutate()}>
107 Clear All
108 </button>
109 </div>
110 </div>
111 `
112 }
113}
114
115class AutoRefetchingApp extends LitElement {

Callers

nothing calls this directly

Calls 1

mutateMethod · 0.45

Tested by

no test coverage detected