examples/preact/rick-morty-preact-iso
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Preact Query Rick And Morty Example (preact-iso)#
A multi-page Rick and Morty app with characters and episodes, where each page fetches its own data.
Built with preact-iso.
How it works#
src/services/characters/queries.ts,src/services/episodes/queries.ts, andsrc/services/locations/queries.tsdefinequeryOptionsfactories (charactersQueries,episodesQueries,locationsQueries) for the Rick and Morty API, each keyed by its domain plus'list'or'detail'and an id.src/Layout.tsxdefines thepreact-isoroutes, andsrc/Characters.tsxandsrc/Episodes.tsxload their lists withuseQuery.src/Character.tsxloads one character, then renders anEpisodeand aLocationcomponent that each calluseQuerywith their own detail query.src/Episode.tsxdoes the same for the episode's characters, so a character seen on one page is already cached when it shows up on another.
To run this example:
npm installnpm run dev