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.

Does not work with next js when tools are added

See original GitHub issue

The solution to use dynamic imports worked for react-editor-js but when I load the tools, it has the same error as in issue before. Please fix this.

https://github.com/Jungwoo-An/react-editor-js/issues/31

Error is TypeError: Cannot read property 'holder' of undefined

Here is my code:

import dynamic from 'next/dynamic';

const EditorJS = dynamic(
  () => import('react-editor-js'),
  { ssr: false }
)
const Header = dynamic(
  () => import('@editorjs/header'),
  { ssr: false }
)
const Embed = dynamic(
  () => import('@editorjs/embed'),
  { ssr: false }
)
const Table = dynamic(
  () => import('@editorjs/table'),
  { ssr: false }
)
const Paragraph = dynamic(
  () => import('@editorjs/paragraph'),
  { ssr: false }
)


const EDITOR_JS_TOOLS = {
  header: Header,
  embed: Embed,
  table: Table,
  paragraph: Paragraph,
}

  useEffect(() => {
    setEditorTools(EDITOR_JS_TOOLS)
  }, []);

and for editor

DOES NOT WORK <EditorJS tools={editorTools}/>

WORKS <EditorJS />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
abhik-bcommented, Dec 16, 2020

@abhik-b Can you share codesandbox or code snippet here. I’m stuck with this issue. It’d of great help. TIA

Hi Rahul, Actually I had another issue when I try to unmount this editor which I could not fix so I did not use this editor at all,

However what I did to fix this issue was

  1. create a component(CustomComonent) where I imported the editor and tools
  2. inside the page where I want to render the CustomComponent:
import dynamic from "next/dynamic";

export default function Page() {

  const DynamicComponentWithNoSSR = dynamic(
    () => import("../../components/CustomComponent"),
    { ssr: false }
  );

  return (
    <div>
      <DynamicComponentWithNoSSR />
    </div>
  );
}
0reactions
hatchlicommented, Dec 15, 2020

Would you please share more working code? The examples you are giving don’t make much sense. Where exactly would you integrate the NoSSR function @Jungwoo-An ? Did you mix it with @StarAzure 's “NOSSRComponent”? If you could possible share a codesandebox of this working with Next.js, I would be eternally grateful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Next.js Compiler
Learn about the Next.js Compiler, written in Rust, which transforms and minifies your Next.js application.
Read more >
Advanced Features: Debugging - Next.js
Next, open Chrome's Developer Tools ( Ctrl + Shift + J on Windows/Linux, ⌥ + ⌘ + I on macOS), then go to...
Read more >
Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >
Getting Started | Next.js
Get started with Next.js in the official documentation, and learn more about all our features!
Read more >
Advanced Features: Dynamic Import - Next.js
Dynamically import JavaScript modules and React Components and split your code into manageable chunks.
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