reactjs - 类型 '{ children: string; }' 与类型 'IntrinsicAttributes & IModalProps' 没有共同属性

标签 reactjs typescript office-ui-fabric

这段代码:

import { Modal } from "office-ui-fabric-react/lib/Modal";
import * as React from "react";

export interface ISignInFormProps {
  showModal: boolean;
}

const SignInForm = () => {
  return <Modal>Hello</Modal>;
};

export default SignInForm;

产生以下错误:

(9,11): Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes & IModalProps'.

enter image description here

此 CodePen 不显示任何错误 - https://codepen.io/camden-kid/pen/aMmzKq?editors=0010

问题的原因是什么以及如何解决?

最佳答案

我们已解决此问题。 TypeScript 3.x 暴露了我们样式实用程序的返回值的键入错误,该返回值没有使用 React 的 StatelessComponent 类型,因此没有 children 属性。 PR是here并且应该会在我们的下一个夜间版本中提供。

关于reactjs - 类型 '{ children: string; }' 与类型 'IntrinsicAttributes & IModalProps' 没有共同属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54987235/

相关文章:

javascript - 如何在基于类的组件中的函数内部抛出 react 警报

typescript - 如何解决/抑制 IntelliJ 警告,即模拟类未在任何 Angular 模块中声明?

javascript - 什么符号/标记集代表 JavaScript 中不为 null 或未定义的所有内容?

javascript - 启用 DatePicker 的特定日期

reactjs - 如何测试 react 响应标签内的 react 组件

reactjs - react : If you set state in a request animation frame will react schedule rendering on the animation frame?

reactjs - 如何使用React和Spring Boot连接docker-compose

node.js - 'ObjectId' 仅指一种类型,但在此处用作值。ts(2693)

reactjs - React Context API 很慢

office-ui-fabric - 如何在 Fabric DetailsList 中呈现包含文本和工具提示图标的列标题