margox / braft-editor

美观易用的React富文本编辑器,基于draft-js开发
MIT License
4.61k stars 593 forks source link

window is not defined #755

Closed chenghung closed 4 years ago

chenghung commented 4 years ago

I got below error when using braft-editor with next.js

the version braft-editor is "v2.3.9"

ReferenceError: window is not defined
    at Object.<anonymous> (my_project/node_modules/braft-editor/dist/index.js:10:4)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
chenghung commented 4 years ago

there is a solution provided by next.js can solve this issue.

https://nextjs.org/docs/advanced-features/dynamic-import