import React from "react";
import { ThemeContext } from "./Theme";

const ToggleTheme: React.FC = () => {
  const { theme, setTheme } = React.useContext(ThemeContext);
  const toggle = () => {
    if (theme === "light") setTheme("dark");
    else if (theme === "dark") setTheme("light");
  };
  return <button onClick={toggle}>Change themes</button>;
};

export default ToggleTheme;
