react-email-editor icon indicating copy to clipboard operation
react-email-editor copied to clipboard

window is not defined error with Remix 2.0

Open wdj82 opened this issue 1 year ago • 4 comments

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

wdj82 avatar Oct 10 '23 14:10 wdj82

It also works on v1.7.8 on [email protected]

jamiemcconnell avatar Oct 10 '23 19:10 jamiemcconnell

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

wdj82 avatar Oct 10 '23 19:10 wdj82

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.

DerJacques avatar Oct 23 '23 20:10 DerJacques

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

hojjatramezani avatar Dec 10 '23 05:12 hojjatramezani