unlayer / react-email-editor

Drag-n-Drop Email Editor Component for React.js
https://unlayer.com/embed
MIT License
4.51k stars 728 forks source link

window is not defined error with Remix 2.0 #364

Closed wdj82 closed 1 month ago

wdj82 commented 10 months ago

Trying to upgrade my project to remix 2.0. In remix 1.8 I have no problem with react-email-editor v1.7.7.

Upgrading to remix 2.0 I'm getting the following error: image

I get the same error in remix 1.8 with newer versions but not 1.7.7

jamiemcconnell commented 10 months ago

It also works on v1.7.8 on remix@2.0.1

wdj82 commented 10 months ago

I did get it working after more fiddling with remix settings. Seems it has to be set for cjs and not esm. But still get the window not defined error with 1.7.9

DerJacques commented 10 months ago

I don't think the issue is strictly related to Remix. The problem was likely introduced in this commit (@brunolemos FYI).

The problem is that window.__unlayer_lastEditorId = window.__unlayer_lastEditorId || 0; is executed as a side effect as soon as the file is imported. This breaks SSR for any file that includes react-email-editor.

Going back to version 1.7.8 of react-email-editor fixes the problem.

hojjatramezani commented 8 months ago

I am using Nextjs version 13.0.0 or 13.4.7. But there is this problem for me. Both on version react-email-editor 1.7.8 and on version react-email-editor 1.7.9 2023-12-10 09_00_19-Window . . This problem occurs when I want to build