josepdecid liked a comment+100 XP
4mos ago
josepdecid liked a comment+100 XP
4mos ago
@josepdecid yeah, all of the TanStack ecosystem is really, really nice.
josepdecid wrote a comment+100 XP
4mos ago
I can't recommend TanStack Query enough!
On top of all the benefits that @simonswiss commented regarding the easy handling of loading and errors, invalidation, caching... it's also super handy to use if we're using TS.
It has a very clever typing for the data-loading-error triad where, as an example it types data as undefined if loading is true or there are some errors. So if you try to access data before checking the loading state or presence of errors your IDE will raise some errors, catching many issues early in the development process!
josepdecid wrote a comment+100 XP
4mos ago
@ApolloBLN if you're confused about the type assigned to setLiked prop is kinda simple at the end. If you hover any setState function (i.e. the second value returned from the useState hook), you will see that it has a type of Dispatch<SetStateAction<T>> where T is the type of your state (in the example is number[].
At this point you can just use this type when you want to pass it down to another component by simply changing the T, but if you want to understand what it means we can separate it with the two combined types:
type Dispatch<A> = (value: A) => void- function that takes something and returns nothing
- way to abstract the type giving it a name and being able to reuse it in other similar hooks such as
useReducer.
type SetStateAction<T> = T | ((prevState: T) => T)- either a value of type T (e.g.
number[]) - or as mentioned in the previous video, a callback-like function that has the previous value
- either a value of type T (e.g.
Combining both basically means that a setState function is a function that receives a value of type T (setState(1)) or a function that receives a type T and returns another type T (setState((prev) => prev + 1))`.
josepdecid wrote a reply+100 XP
5mos ago
After several years (2025) , validation for nested fields is now fully supported in Inertia 2.x without having do some hacks to get it working and proper typing if using TS, to thanks to this PR: https://github.com/inertiajs/inertia/pull/2181
josepdecid wrote a comment+100 XP
5mos ago
Inertia 2 updates (2025)
In case someone is watching this after a few years (this video is from 2021) with the release of Inertia 2.0, now we ahve the Form component and useForm helpers.
The way to work with forms is basically still the same but now it feels much more integrated into the framework with the usage of useForm along with several other improvements...
Worth checking the new Inertia Form docs!
josepdecid liked a comment+100 XP
5mos ago
josepdecid liked a comment+100 XP
5mos ago