Spending more time with Tanstack DB this week and it's finally clicking
Spending more time with Tanstack DB this week and it's finally clicking. Lot's of little "ah ha" moments.
Here's an example.
In typical React, I'd:
1. Fetch data from a REST endpoint
2. Store the data to state so I could change it in form
3. Populate state via a useEffect when the query resolves
4. Cache the query result via Tanstack query by declaring a query key
5. Derive state via separate variables as needed
In contrast, Tanstack DB handles all that in a "live query". I can even derive state inline within the query.
Note what I didn't need:
-No useState
-No useEffect
-No separate variables for derived state
-No query keys
-No custom hooks
I just query the collection using a type safe query language.

Correction - there's still a query key involved, but it is declared in the collection boilerplate.
Here's a collection for food.
This wires up Tanstack DB to interact with a REST API. Note that most of this is simple CRUD boilerplate.
