import React, { useState, useEffect } from "react"; // ToggleButton: A reusable and semi-controlled toggle button export default function ToggleButton({ initialChecked, onToggle, name }) { const [isChecked, setIsChecked] = useState(initialChecked); useEffect(() => { setIsChecked(initialChecked); }, [initialChecked]); const handleToggle = () => { setIsChecked(!isChecked); if (onToggle) { onToggle(!isChecked); } }; return ( ); }