How to manage 'data is undefined' - TanStack