2
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.

[react-konva] Next.jsでReactKonvaCore.js not supported.

Last updated at Posted at 2022-05-07

[react-konva] ReactKonvaCore.js not supported.エラーを解決

Next.jsにてreact-konvaを使おうとしたら、以下のエラーが出ました。

**require() of ES Module /Users/~~~/node_modules/konva/lib/Core.js from /Users/~~~/node_modules/react-konva/lib/ReactKonvaCore.js not supported.
Instead change the require of Core.js in /Users/~~~/node_modules/react-konva/lib/ReactKonvaCore.js to a dynamic import() which is available in all CommonJS modules.**

こんな感じで、ssrなしのコンポーネントとして設定してあげると解決できます。

import dynamic from 'next/dynamic'

const SampleComponent = () => {
	return <NoSSRComponent
      propsA={'sampleA'}
      propsB={'sampleB'}
  />
}

const NoSSRComponent = dynamic(() => import('../../SampleCanvas'), {
  ssr: false,
})

このissueを参考に解消しました。

2
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
2
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?