import React, { useState, useEffect, useContext } from 'react' import './App.css' import axios from 'axios'; import { CartContext } from './CartContext'; import Cart from './Cart'; import CartNoContext from './CartNoContext'; const App = () => { const [count, setCount] = useState(0) // const [color, setColor] = useState("red"); const [text, texty] = useState("My favorite color is red!"); const [callApi, setCallApi] = useState(false); // useEffect( // () => {} // , // [] // ) useEffect( () => { if (callApi === true) { axios.get('https://jsonplaceholder.typicode.com/posts/1') .then((response) => { console.log(JSON.stringify(response)) }) .catch((error) => { console.error(error) }) } else { console.log("API is not called") } } , // [] // when left empty, it executes the call back function inside the useEffect WHEN THE PAGE LOADS [callApi] ) const { cart, removeFromCart } = useContext(CartContext); // console.log(`cart count ${cart.length}`) // cart.map((price, cakeName) => { // console.log(`${JSON.stringify(price)} ${cakeName}`) // }) return ( <>