0

I have a simple code.

/pages/MyPage.tsx

const React from 'react';

const MyPage = () => {
  React.useEffect(()=>{
    console.log('Mounted..');
  }, []);
  console.log('Rendered..');
  return (<div>MyPage</div>);
};

export const getStaticProps = async ctx => {
  // do something... with ctx;
  return {
    props: {},
  }
};
export default MyPage;

and I entered localhost:3000/MyPage?query=randome,

My browser console is like below that.

Rendered..
Mounted..
Rendered..
Mounted..

I don't know how it mounted twice.

kyun
  • 9,710
  • 9
  • 31
  • 66
  • 1
    Do you have `reactStrictMode` enabled in your `next.config.js`? See [Why is my React component is rendering twice?](https://stackoverflow.com/questions/48846289/why-is-my-react-component-is-rendering-twice). – juliomalves Apr 24 '22 at 16:06

0 Answers0