josepdecid liked a comment+100 XP
4mos ago
I set max level on every project... and I ignore error in rarely (very rarely) situations. I disagree with the suggestion of this video :/
josepdecid liked a comment+100 XP
5mos ago
@josepdecid yeah, all of the TanStack ecosystem is really, really nice.
josepdecid wrote a comment+100 XP
5mos 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
5mos 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
6mos 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