79622607

Date: 2025-05-15 04:19:59
Score: 0.5
Natty:
Report link

From the sandbox, the issue occurs because you're setting the state back to the prop value instead of toggling it.

So, update your state using the new value instead:

const newValue = !enabled;
setEnabled(newValue); // instead of doing setEnabled(value)
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Unclebigbay