React-query: return undefined instead of null

Created on 13 Jan 2020  路  2Comments  路  Source: tannerlinsley/react-query

Improvement

the default returnValue of data at least in useQuery should be undefined instead of null

if you return undefined then you can make use of set default values as shown below

 const { data = [] } = useQuery(
    'TrendingShows',
    loadTrendingShows
  );

Most helpful comment

This will be fixed in the next release 馃帀

All 2 comments

I agreed with your recommendation. But as a workaround for now, you can use the initialData prop as described here to set your data to an empty array for example
https://github.com/tannerlinsley/react-query#ssr--initial-data

This will be fixed in the next release 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivowork picture ivowork  路  5Comments

aleksandarcrvc picture aleksandarcrvc  路  3Comments

bgazzera picture bgazzera  路  4Comments

GuillaumeSpera picture GuillaumeSpera  路  5Comments

lgenzelis picture lgenzelis  路  4Comments