()
| 29 | } |
| 30 | |
| 31 | function Example() { |
| 32 | const query = useQuery(() => reposQueries.detail()) |
| 33 | |
| 34 | return ( |
| 35 | <Switch> |
| 36 | <Match when={query.isPending}>Loading...</Match> |
| 37 | <Match when={query.isError}> |
| 38 | {`An error has occurred: ${query.error?.message}`} |
| 39 | </Match> |
| 40 | <Match when={query.data}> |
| 41 | {(data) => ( |
| 42 | <div |
| 43 | style={{ |
| 44 | 'padding-bottom': '20px', |
| 45 | }} |
| 46 | > |
| 47 | <h1>{data().full_name}</h1> |
| 48 | <p>{data().description}</p> |
| 49 | <strong>👀 {data().subscribers_count}</strong>{' '} |
| 50 | <strong>✨ {data().stargazers_count}</strong>{' '} |
| 51 | <strong>🍴 {data().forks_count}</strong> |
| 52 | <div>{query.isFetching ? 'Updating...' : ''}</div> |
| 53 | </div> |
| 54 | )} |
| 55 | </Match> |
| 56 | </Switch> |
| 57 | ) |
| 58 | } |
| 59 | |
| 60 | const rootElement = document.getElementById('root') |
| 61 | if (!rootElement) throw new Error('Missing #root element') |
nothing calls this directly
no test coverage detected