Can you explain this react function?

This is the function that fetches the products from the database for the products page of a eCommerce website.

I am trying to write a similar function for sign-in.

Can you help me with that I am new to react?

storedProducts = () => {
    .then(res => {
      const storedProducts =;
      let tempProducts = [];
      storedProducts.forEach(item => {
        const singleItem = { ...item
        tempProducts = [...tempProducts, singleItem];

      this.setState(() => {
        return {
          products: tempProducts


In each iteration the current item of the storedProduct is cloned into a new object (singeItem). In the next line this singleItem is appended to a new array that is reassigend to tempProducts. tempProducts is a complete new array object created using the spread operator.