I am trying to change the color of the background of my whole React App on button click. However, I only change the color of the button itself. I am importing the App.css into my app and I want to dynamically change the CSS of the App from a separate function called ChangeColor. This function is then placed in my Header.js that is then placed in the App.js
Is there a way that I can do this? This is my code:
import React, {useState} from "react";
import Button from "react-bootstrap/esm/Button";
import '../../../App.css'
function ChangeColor() {
const [isActive, setIsActive] = useState(false);
const handleClick = () => {
setIsActive(current => !current);
};
return(
<Button
style={{
backgroundColor: isActive ? 'red' : '',
color: isActive ? 'white' : '',
}}
onClick={handleClick}
> Test </Button>
)
}
export default ChangeColor
.App {
text-align: center;
background-color: white;
}