score:0

Accepted answer

setcollections is not executed immediately by react. the new state should be available on the next render. try logging during the render phase:

const [error, seterror] = usestate(null);
const [isloaded, setisloaded] = usestate(false);
const [collections, setcollections] = usestate([]);

console.log(collections);

useeffect(() => {
  ...
}, [])

Related Query

More Query from same tag