Advertisement
Guest User

Untitled

a guest
Sep 5th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   const [checkedBoxesDate, setCheckedBoxesDate] = useState([]);
  2.  
  3. // 1. Działa
  4.   const handleCheckBoxDate = (position1, position2) => {
  5.     const chkBoxesCopy = JSON.parse(JSON.stringify(checkedBoxesDate)); // deep copy
  6.     chkBoxesCopy[position1][position2] = !chkBoxesCopy[position1][position2];
  7.     setCheckedBoxesDate(chkBoxesCopy);
  8.   }
  9.  
  10.   // 2. Nie działa ?
  11.   const handleCheckBoxDate = (position1, position2) => {
  12.     setCheckedBoxesDate((chkBoxes)=>{
  13.       chkBoxes[position1][position2] = !chkBoxes[position1][position2];
  14.       return chkBoxes;
  15.     })
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement