Thank you for seeing this code. please take a look
import React, { Fragment, useEffect, useState } from "react";
export default function App() {
const [starterModal, setStarterModal] = React.useState(true);
useEffect(() => {
let cronInterval = setInterval(() => {
console.log(starterModal);
}, 4000);
setStarterModal(false);
}, []);
return (
<div className="App">
<h1>Hello CodeSandbox </h1>
<h1>starterModal {starterModal ? "True" : "False"} </h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}
My expected output of the state value is false. why the log print true inside setInterval