For some reason with this code the alert is displayed twice. Why is this? All people with similar issues seem to be using React in strict mode. How do I turn off strict mode if its somehow on by default for me. And if that's not the issue, what is?
import React from "react";
import { createRoot } from 'react-dom/client';
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
import { useState, useEffect } from "react";
import ReactDOM from "react-dom/client";
function Main()
{
const [count, setCount] = useState(20);
//setInterval(setCount(count - 1), 1000);
useEffect(() => {
setTimeout(() => {
setCount((count) => count > 0 ? count - 1 : alert("boom"));
}, 1000);
});
return(
<div> {count} </div>
)
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Main />);