1Shubham7 / Wife-Predictor-v2

This is a fun project that predicts your wife. The web app has been deployed on Netlify.
https://wife-predictor.netlify.app/
MIT License
26 stars 27 forks source link

Alter how boolean are changed #23

Open theQuery opened 1 year ago

theQuery commented 1 year ago

Currently, some of the boolean changes are prone to errors during rerenders (like the last one), so to adhere to best practice, it should be changed. I also think refactoring ones like the first one would also be good to encourage better readability:

 function handleClick() { 
-     if (isChecked === false) { 
-       setIsChecked(true); 
-     } else { 
-       setIsChecked(false); 
-     }
+     setIsChecked(oldIsChecked => !oldIsChecked)
 } 

 function checkboxon() { 
-     setIsActive(!isActive);
+     setIsActive(oldIsActive => !oldIsActive)
 }
1Shubham7 commented 1 year ago

Go Ahead Bro