fetchDatafetchData. Then to stop continuous re-rendering I use useRef instead of useState to set two arrays cdatacdata and pdatapdata. Their console.logconsole.log shows it worked. onclickonclick neither cdatacdata nor pdatapdata are available. useEffectuseEffect as I need my data to be available after onclickonclick and fetchDatafetchData within useEffectuseEffect means it is only available after the page re-renders. Not at onclickonclick.Join the Discord to ask follow-up questions and connect with the community