question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors rendering Editor in Next.js

See original GitHub issue

Bug Description

I was trying to create Story Editor in Next.js however there were several errors that appear one after the other ( Most of them are due to Next.js SSR )

image

( Gets fixed by removing CSS import ) Reference: https://nextjs.org/docs/messages/css-npm

image

( Gets fixed by using globalThis )

image

( Gets fixed by removing "type": "module" from package.json )

image

image

image

image

image

image

Expected Behaviour

Editor and dashboard should work without any issues in NextJs.

Steps to Reproduce

Step - 1: npx create-next-app@latest

Step - 2: Use snippet from getting-started to use the editor

Screenshots

Additional Context

  • Plugin Version:
  • WordPress Version:
  • Operating System:
  • Browser:

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
sayedtaquicommented, Apr 14, 2022

Just adding a note here for reference.

We can ignore document/window/self or similar things if:

  • They are used inside useEffect/useLayoutEffect hooks because they are not called during SSR.
  • They are called inside a callback or internal function which are not directly called during rendering.
  • They are inside try/catch
1reaction
swissspidycommented, Apr 14, 2022

Ah right, yeah that makes sense. Because we import CSS files in wp-story-editor and wp-dashboard that wouldn’t work. An ESLint rule is a great idea 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Error Handling - Next.js
Render a fallback UI after an error is thrown; Provide a way to reset the Application's state; Log error information. You can create...
Read more >
Testing and error handling patterns in Next.js - LogRocket Blog
Check out these different ways to run tests and handle errors in Next.js apps using Cypress, a JavaScript-based testing framework.
Read more >
Troubleshooting JSS Next.js apps - Sitecore Documentation
If your app renders and builds correctly in your local development environment, but fails to render when deployed to Vercel, a possible reason ......
Read more >
not working in next js correctly · Issue #31 · Jungwoo-An/react ...
hi I imported this in Nextjs,dynamic because error for window but most plugin don't work. ... Check the render method of `Editor`.
Read more >
How to solve "window is not defined" errors in React and Next.js
Next.js is a React framework with pre-rendering abilities. This means that for every page, Next.js... Tagged with javascript, nextjs, errors ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found