Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

josepdecid's avatar

josepdecid liked a comment+100 XP

4mos ago

Static Analysis with PHPStan: Ep 3, Ignoring Errors

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's avatar

josepdecid liked a comment+100 XP

5mos ago

React from Scratch: Ep 21, Data Fetching With useEffect

@josepdecid yeah, all of the TanStack ecosystem is really, really nice.

josepdecid's avatar

josepdecid wrote a comment+100 XP

5mos ago

React from Scratch: Ep 21, Data Fetching With useEffect

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's avatar

josepdecid wrote a comment+100 XP

5mos ago

React from Scratch: Ep 15, Sharing State Across Components

@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

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's avatar

josepdecid wrote a reply+100 XP

6mos ago

Validation Errors For Nested Fields

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