Working on React and I dont understand what prev does here

Hey! I’m working on the react part 2 and I’m struggling to understand how the hooks work here:

export default function GroceryCart() {
  // declare and initialize state 
  const [cart, setCart] = useState([]);
  const addItem = (item) => {
    setCart((prev) => {
      return [item, ...prev];
    });
   };

What I dont understand is where the prev is coming from in the setCart call. There are no variables called prev si i dont understand what is going in there. If you could explain that would be awesome! Thanks!

Have a look at these posts:

Share your thoughts if you still find something confusing.