0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【NextJS】Uncaught RangeError: Maximum call stack size exceededの対処法

Posted at

きっかけはWebアプリ制作時。。。

Uncaught RangeError: Maximum call stack size exceeded

またチミか。

原因

端的に言えば、変数やNextJSの場合はコンポーネントの入れ子構造をやりすぎるとこうなるようです。

エラー例

修正前

export default function Box ({children}:any) {
    return (
      <div style={{backgroundColor: "black", color: "white"}}>
        {children}
      </div>
    )
}

// ここと
const BoxInnder = ({children}:any) => {
    return (
        <Box>
            <h1>code test</h1>
            
        </Box>
    )
}

// ここで入れ子の読み込みがほぼ無限に起こっている(?)
const BoxInnderContent = ({children}:any) => {
    return (
        <BoxInnder>
            <h1>code test</h1>
            
        </BoxInnder>
    )
}

よい子はextendsを使いましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?