React & Slate 的 TypeScript 错误:属性'renderElement'在类型 'IntrinsicAttributes' 上不存在



我正在尝试学习如何使用Slate相对于以下教程:定义自定义元素。

我添加了以下代码(遵循教程略有风格变化):

export default function App() {
const renderElement = useCallback((props) => {
switch (props.element.type) {
case "code":
return <Code {...props} />
default:
return <Default {...props} />
}
}, [])
return <Editor renderElement={renderElement} />
}
问题是我得到以下TypeScript错误:
Type '{ renderElement: (props: any) => Element; }' is not assignable to type 'IntrinsicAttributes'.
Property 'renderElement' does not exist on type 'IntrinsicAttributes'. ts(2322)

知道为什么我得到这个错误以及如何修复它吗?

我不熟悉有问题的库,但从您链接的文档中,看起来renderElementprop是在<Editable />组件上,而不是<Editor />。这是问题所在吗?

最新更新