Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

To get a short name for data from a react-query

here is my code

const { data , isLoading, ...} = useInfo();

console.log(data?.data.payload.info);

‘useInfo’ is react-query hook i made.
data?.data.payload.infois is too long..

i want to use data name with no deps

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there a way to use it as below?

console.log(info) => returns data only i need 

teach me the way and sorry for my poor English 🥲🥲🥲🥲

>Solution :

Destructure the info property of data.data.payload.

const { info } = data?.data.payload;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading