javascript - React 和 Slate 的 TypeScript 错误:“IntrinsicAttributes”类型上不存在属性“renderElement”
问题描述
我正在尝试通过以下教程学习如何使用 Slate: Defining Custom Elements。
我已经(按照教程进行了轻微的风格更改)添加了以下代码:
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)
知道为什么我会收到此错误以及如何解决它吗?
解决方案
我不熟悉有问题的库,但从您链接的文档看来,renderElement
道具在<Editable />
组件上而不是<Editor />
. 这可能是问题吗?
推荐阅读
- python - 如何编写 python 程序计算 n+nn+nnn+nnnn+... nn...n 的值 ntimes 给定的数字作为 n 的值
- java - 用按钮链接气泡选择器中的气泡
- python - 为什么 df.cumsum() 给出 ValueError: Wrong number of items passed, placement 意味着 1
- performance - 了解elasticsearch慢查询日志格式
- arrays - 如何在汇编语言中切换数组的第一个和第二个、第三个和第四个等元素并以 dec 输出?
- javascript - 反应钩子useState不能存储json或字符串
- python - 我将图片转换为 GIF,但海龟的 bgpic() 仍然无法正常工作
- .net - 使用 moq 在 xunit 中更新操作
- typescript - 使用 Lerna、Typescript 和 VS Code 将某些路径排除在自动导入之外
- bash - 如何将“ls”输出附加到文本文件中前一行的末尾,中间有空格?