- Joined
- Mar 9, 2023
- Messages
- 3
- Reaction score
- 0
I am trying to use switch in bootstrap in order to enable DarkMode
However, the textArea does not change,
Here is App.js code,
Code:
<div
className="container"
style={{ color: props.mode === "dark" ? "white" : "black" }}
>
<h1>{props.heading}</h1>
<div className="form-group">
<textarea
className="form-control"
value={text}
id="exampleFormControlTextarea1"
rows="8"
onChange={handleOnChange}
style={{
backgroundColor: props.mode === "dark" ? "grey" : "white",
color: props.mode === "dark" ? "white" : "black",
}}
></textarea>
</div>
However, the textArea does not change,
Here is App.js code,
JavaScript:
function App() {
const [mode, setMode] = useState("light");
const toggleMode = () => {
if (mode === "light") {
setMode("dark");
document.body.style.backgroundColor = "grey";
} else {
setMode("light");
document.body.style.backgroundColor = "white";
}
};
return (
<>
<Navbar title="TextUtils" mode={mode} toggleMode={toggleMode} />
<div className="container">
<TextForm
heading="Write your text here"
button1="Convert To Uppercase"
button2="Convert To LowerCase"
button3="Clear"
/>
</div>
</>
);
}
Last edited: