React. Strict Mode. Double render. Initial alert banner displayed twice
Unanswered
Virginia's Warbler posted this in #help-forum
Virginia's WarblerOP
At the beginning, I need to display an alert at the beginning, hence I use
But the Strict Mode 2x render messes that up.
I know I shouldnt rid Strict Mode.
So how can I tackle this problem.
I tried to use a flag but below didnt work
useEffect.But the Strict Mode 2x render messes that up.
I know I shouldnt rid Strict Mode.
So how can I tackle this problem.
I tried to use a flag but below didnt work
const [checked, setChecked] = useState(false)
useEffect(() => {
console.log(checked);
if (!checked)
{
checkForAlerts(); // Display alert banner
setChecked(true);
}
}, [checked]);3 Replies
it this the same error as here: https://nextjs-forum.com/post/1286295138922004500#message-1286295138922004500 ?
Virginia's WarblerOP
No no, seperate question
ah ok