Home > Software engineering >  React State wasn't changed after I clicked a switch to send a current state to server
React State wasn't changed after I clicked a switch to send a current state to server

Time:12-16

Would you please explain this to me why it's sending relay1 state with false? Why handleControlRelay1 doesn't change the state I'm doing it wrong by putting this inside a function? setRelay1((prevValue) => !prevValue);

// ...

  const [relaysData, setRelaysData] = useState([]);
  console.log("           
  • Related