Is there a way to change the import of a CSS file in React App? For instance, having a light and dark mode and allowing the user toggle between them.
Attempted this but it didn't work:
`const [useStyle1, setUseStyle1] = useState(true);
const toggleStyle = () => {
setUseStyle1(!useStyle1);
};
{useStyle1 ? (
<link rel="stylesheet" type="text/css" href="./App.css" />
) : (
<link rel="stylesheet" type="text/css" href="./App2.css" />
)}
<h1>Hello, World!</h1>
<button onClick={toggleStyle}>Toggle Style</button>`