React query in typescript strict mode
Hi everyone,
I am working in a company where we recently updated typescript in strict mode, so it means the
So now, if I am writing code like this, typescript will raise an error:
The fix:
Now, I have data that is fetched once at the top of the tree when the app initialize, it returns some global permissions configuration for the logged user.
However this hook is used in several nested sub-component of the app preventing props-drill.
My question is related to react-query best practices:
(1) Should we handle errors on all nested components ?
- It makes the component typesafe and resilient to potential refactor issues
- It adds lots of boilerplate and redundant code
(2) Should we use optional chaining everywhere
- Not a huge fan of this, because in case of errors it can fail silently, Plus it is noisy and not typesafe
(3) ?
I am working in a company where we recently updated typescript in strict mode, so it means the
strictNullCheck value will be activated.So now, if I am writing code like this, typescript will raise an error:
The fix:
Now, I have data that is fetched once at the top of the tree when the app initialize, it returns some global permissions configuration for the logged user.
However this hook is used in several nested sub-component of the app preventing props-drill.
My question is related to react-query best practices:
(1) Should we handle errors on all nested components ?
- It makes the component typesafe and resilient to potential refactor issues
- It adds lots of boilerplate and redundant code
(2) Should we use optional chaining everywhere
- Not a huge fan of this, because in case of errors it can fail silently, Plus it is noisy and not typesafe
(3) ?