Often when we have too much business logic in one file, it tends to become hard to read and manage. On top of that, there might be some parts of that logic that we want to abstract so we can use it in other parts of our application.
We can abstract our shopping cart state by creating a custom React hook that we can use in our store to more easily maintain our app. You'll see how much simpler our Home page looks after moving the cart logic out!
Error As:
Unhandled Runtime Error ReferenceError: cartItems is not defined
Why are you importing: import { useState } from 'react' to the Index.js file?
import { useState } from 'react'
This is so that the instructor can use this React Hook to set state for his cart.