Build a component that toggles between light and dark themes with a button click.
MediumProblem Statement
Build a component that toggles between light and dark themes with a button click.
Sample Input
Initial theme: 'light'
Sample Output
Background color switches between white and black.
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React, { useState } from "react"; const ThemeToggler = () => { return ( <div> <button>Toggle Theme</button> </div> ); }; export default ThemeToggler;