Invalid hook call. Hooks can only be called inside of the body of a function component.

Milkiyas
New Member
2 0 0
const submitHandler = useCallback(() => {
    let count = 0
    const runMutation = (product) => {
      updateProduct({
        variables: {
          input: {
            descriptionHtml: `${product.descriptionHtml}${descriptionValue}`,
            title: `${product.title}${titleValue}`,
            id: product.id
          }
        }
      }).then((data) => {
        console.log('Update product', count, data);
        count++;
        if(products[count]) runMutation(products[count])
        else {
          console.log('Update complete');
          setShowToast(true);
        }
      })
    }
    runMutation(products[count])
  
  }, [products, descriptionValue, titleValue]);
Replies 0 (0)