score:2

one possible solution could be, usecallback hook. it will solve your problem of unnecessary re-rendering. i.e.

const [items, setitems] = usestate<t[]>([] as t[])


const loadprimarydata = usecallback(async () => {
 const data = await fetchprimarydata();
 setitems(data);
}, []);

const loadsecondarydata = usecallback(async () => {
 for (const item of data) {
  await secondaryrequest(item)
  setitems([...data])
}}, [data]);

further, if you want to load data one after another, depending on your use-case, you can use useeffect hook.


Related Query

More Query from same tag