examples/solid/basic
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Basic Example#
A list of posts and a post detail view. Posts you have already opened are marked as visited from the query cache.
How it works#
src/services/posts/queries.tsdefinespostsQueries.list()andpostsQueries.detail(id)withqueryOptions, keyed by['posts', 'list']and['posts', 'detail', id].src/services/posts/api.tsfetches the posts from JSONPlaceholder.src/index.tsxpasses these options touseQueryin thePostsandPostcomponents and shows "Background Updating..." whileisFetchingistrue. TheQueryClientsets a 24-hourgcTime, so opened posts stay in the cache.- The
Postslist callsqueryClient.getQueryData(postsQueries.detail(post.id).queryKey)to style links whose detail is already cached.
To run this example:
npm installnpm run dev