toggle switch using useState
import React, { useState } from 'react';
function ToggleSwitch() {
const [value, setValue] = useState(false);
function toggleHandler {
setValue(value => !value);
console.log(value);
}
return (
<button onClick={toggleHandler} > Click Me </button>
)
}