Jungwoo-An / react-editor-js

⚛️📝The unofficial editor-js component for React
https://codesandbox.io/s/react-editor-js-v2-34bfl
MIT License
954 stars 77 forks source link

Window not defined error when trying to build #150

Closed surajpalwe closed 2 years ago

surajpalwe commented 3 years ago

Hello,

As mentioned in title I'm facing the error when I'm trying to build.

When I run npm run on my machine with below fix, I get the editor working, but when I'm trying to build it is throwing me that error.

My code is as follows.

     const EditorJsWithNoSSR = dynamic(() => import("./RichEditor"), {
      ssr: false,
      loading: () => <p>loading editor.js ...</p>,
     });
<EditorJsWithNoSSR saveEditorData={this.handleCallback} />
//this is how I'm calling the component.

And below is the build error.

> Build error occurred
ReferenceError: window is not defined
    at Object.<anonymous> (D:\trekproject-UI\trekproject-blog\node_modules\@editorjs\editorjs\dist\editor.js:4:7)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at D:\trekproject-UI\trekproject-blog\node_modules\react-editor-js\dist\react-editor-js.umd.js:2:111
    at Object.<anonymous> (D:\trekproject-UI\trekproject-blog\node_modules\react-editor-js\dist\react-editor-js.umd.js:5:2)
    at Module._compile (internal/modules/cjs/loader.js:1085:14) {
  type: 'ReferenceError'
}

Environment

What changes should be made or am I missing something?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Jungwoo-An commented 2 years ago

@surajpalwe Hi! First of all, thanks for your interest! 👋

editor-js library does not yet support SSR. You can using workaround.

Thanks!