Skip to content

Objects are not valid as a React child (found: [object Error]). #17

Description

@mihaiicey

Hi,
I have an error when I click to view a file created with Editor.js, the problem occurs only when there is a table in it, on the default it works fine.

Unhandled Runtime Error
Error: Objects are not valid as a React child (found: [object Error]). If you meant to render a collection of children, use an array instead.

The error when converting to HTML from string, on this page:


import { OutputData } from "@editorjs/editorjs";
import React from "react";
import editorJsHtml from "editorjs-html";
const EditorJsToHtml = editorJsHtml();

type Props = {
  data: OutputData;
};
type ParsedContent = string | JSX.Element;

const EditorJsRenderer = ({ data }: Props) => {
  const html = EditorJsToHtml.parse(data) as ParsedContent[];
  return (
    <div className="prose ContractTemplate max-w-full" key={data.time}>
      {html.map((item, index) => {
        if (typeof item === "string") {
          return (
            <div dangerouslySetInnerHTML={{ __html: item }} key={index}></div>
          );
        }
        return item;
      })}
    </div>
  );
};

export default EditorJsRenderer;

I think it's because you return: string[][]. To be honest I don't know how to fix this.
A little help?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions