'How do I manipulate data based on another data in Redux Toolkit (React)?

const { data, isLoading } = useGetDataQuery({ skip: !dependency } );

const { data2, isLoading2 } = useGetData2Query({ skip: !data } );

const { data3, isLoading3 } = useGetData3Query({ skip: !data2 } );

Now the problem is that both data2 and data3 will run because on pageload data and data2 is undefined

How can I work around this issue? Can I make it wait for them to be defined?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source