Next.js Discord

Discord Forum

Can some explain why StrictMode no longer seems to re-run the effects twice in dev mode with latest?

Unanswered
Ragdoll posted this in #help-forum
Open in Discord
RagdollOP
I have a very simple client component
'use client';

import { useState, useEffect } from 'react';

const Counter = () => {
  const [count, setCount] = useState(0);

  useEffect(() => {
    console.log('Counter component mounted');
    return () => {
      console.log('Counter component unmounted');
    };
  }, []);

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
};

export default Counter;

I expected to see the console log in the useEffect twice but do not...

with pnpm create next-app@latest

but i do with pnpm create next-app@14

I tried downgrading react to v18 because i thought maybe react updated how strict mode worked..but same thing...

0 Replies