Advertisement
informaticage

React - fix attempt

Oct 24th, 2021
1,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const [isRipetitive, setIsRipetitive] = useState(false);
  2.  
  3. const [daysOfWeek, setDaysOfWeek] = useState({
  4.   'lunedì': false,
  5.   'martedì': false,
  6.   'mercoledì': false,
  7.   'giovedì': false,
  8.   'venerdì': false,
  9.   'sabato': false,
  10.   'domenica': false
  11. });
  12.  
  13. const pickDaysOfWeek = (day) => {
  14.   setDaysOfWeek({ ...daysOfWeek, [day]: !daysOfWeek[day] });
  15. }
  16.  
  17. {
  18.   isRipetitive &&
  19.     <View>
  20.       {Object.entries(daysOfWeek).map(
  21.         ([day, status]) => (
  22.           <CheckBox
  23.             key={day}
  24.             value={status}
  25.             onClick={pickDaysOfWeek(day)}
  26.           />)
  27.       )}
  28.     </View>
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement