I'm using an object in two different states, in on of the states I just set the object in the state, and the other state I change one of the values in the object before setting state, but when I make the change both of the states change.
  const fetchCategories = () => {
    setAllCategory(categoryList1["movies"]);
    categoryList1["movies"].forEach((i) => {
      setMovies((prev) => {
      i["favmovies"] = [];
      return [...prev, i];
     });
   });
 };
both states return an empty favmovies array
[
    {
        "id": "1",
        "name": "development",
        "image": "img.png",
        "favmovies": []
    },
    {
        "id": "2",
        "name": "socialmedia",
        "image": "img2.png",
        "favmovies": []
    },
    {
        "id": "3",
        "name": "writing",
        "image": "img2.png",
        "favmovies": []
    }
]
 
    