Skip to content
Discussion options

You must be logged in to vote

I don't want to have to null check data and data[key] everywhere the properties are used so I was wondering what experienced users would advise. Thanks!

placeholderData and initialData make sure of this at runtime, but if you use TypeScript, you'll still be forced to null check. Read about the differences between the two settings here: https://tkdodo.eu/blog/placeholder-and-initial-data-in-react-query

destructuring with default values makes sure that you don't have to null check in your component, but you need to come up with defaults.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by curtis-flaming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants