简体   繁体   English

Tinymce React 组件“编辑器”不能用作 JSX 组件

[英]Tinymce React component 'Editor' cannot be used as a JSX component

i am trying to use the React version on Tiny mce.我正在尝试在 Tiny mce 上使用 React 版本。 I am a beginner with react.我是反应的初学者。

When i add the component in mine i got this error at compilation :当我在我的组件中添加组件时,我在编译时遇到了这个错误:

'Editor' cannot be used as a JSX component.
  Its instance type 'Editor' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'ReactElement<{ ref: RefObject<HTMLElement>; id: string; }, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
        Property 'children' is missing in type 'ReactElement<{ ref: RefObject<HTMLElement>; id: string; }, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

My code :我的代码:

import React from "react";
import { Editor } from "@tinymce/tinymce-react";

const Dummy = () => <Editor apiKey={"hgt9dr50djqpx23dm6h18u9dsayv95elris5dxsqlrc0ht37"}
                            init={{...}}
                            onEditorChange={()=>null}/>


export default Dummy;

Thanks :)谢谢 :)

I had a similar issue in the last few days.在过去的几天里,我遇到了类似的问题。 It seems to be related to a typescript update.它似乎与打字稿更新有关。

As a workaround, add the following on the line immediately above the error line.作为一种解决方法,在错误行正上方的行中添加以下内容。

{/* @ts-ignore*/}
<Editor ....

The tells the typescript checker to ignore the following line of code.告诉打字稿检查器忽略以下代码行。

Parentheses needed because of react but the line is just a JS comment but typescript reads it.由于反应需要括号,但该行只是一个 JS 注释,但打字稿会读取它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM