Skip to content

Failed to construct 'HTMLElement': Illegal constructor #9151

@zhang123-bit

Description

@zhang123-bit

Here is my code. How can I resolve this error

import { useEffect, useRef } from 'react';

export default function AffineEditor() {
  const box = useRef<HTMLDivElement>(null);

  useEffect(() => {
    // 动态 import,保证代码只在浏览器执行
    import('@blocksuite/presets').then(({ PageEditor, createEmptyDoc }) => {
      // 注册语句就包含在 @blocksuite/presets 的副作用里,import 一次即可
      const doc = createEmptyDoc().init();
      const editor = new PageEditor();
      editor.doc = doc;
      box.current?.appendChild(editor);
    });
  }, []);

  return <div ref={box} style={{ height: '100vh' }} />;
}

Failed to construct 'HTMLElement': Illegal constructor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions