()
| 50 | } |
| 51 | |
| 52 | export default function Example() { |
| 53 | const [selectedChar, setSelectedChar] = createSignal(1) |
| 54 | |
| 55 | const charactersQuery = useQuery(() => ({ |
| 56 | ...charactersQueries.list(), |
| 57 | throwOnError: true, |
| 58 | })) |
| 59 | |
| 60 | return ( |
| 61 | <div class="App"> |
| 62 | <p> |
| 63 | Hovering over a character will prefetch it, and when it's been |
| 64 | prefetched it will turn <strong>bold</strong>. Clicking on a prefetched |
| 65 | character will show their stats below immediately, and opening its |
| 66 | details page will render it without a loading state. |
| 67 | </p> |
| 68 | <h2>Characters</h2> |
| 69 | <ErrorBoundary fallback={(error) => <span>Error: {error.message}</span>}> |
| 70 | <Suspense fallback="Loading..."> |
| 71 | <ul> |
| 72 | <For each={charactersQuery.data?.results}> |
| 73 | {(char) => ( |
| 74 | <CharacterItem char={char} onSelect={setSelectedChar} /> |
| 75 | )} |
| 76 | </For> |
| 77 | </ul> |
| 78 | |
| 79 | <h3>Selected Character</h3> |
| 80 | <Suspense fallback="Loading..."> |
| 81 | <SelectedCharacter id={selectedChar()} /> |
| 82 | </Suspense> |
| 83 | </Suspense> |
| 84 | </ErrorBoundary> |
| 85 | </div> |
| 86 | ) |
| 87 | } |
nothing calls this directly
no test coverage detected