Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mihaiicey opened this issue Sep 13, 2023 · 0 comments
Open

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

mihaiicey opened this issue Sep 13, 2023 · 0 comments

Comments

@mihaiicey
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant