JSX元素类型“查询”不是JSX元素的构造函数

时间:2018-10-01 09:33:02

标签: typescript graphql apollo react-apollo

遇到此打字稿错误。尝试使用Person中的Query组件。

react-apollo

版本:

JSX element type 'Query<any, { id: number; }>' is not a constructor function for JSX elements.
  Property 'setState' is missing in type 'Query<any, { id: number; }>'.
[ts] JSX element class does not support attributes because it does not have a 'props' property.
[ts] Property 'query' does not exist on type '{}'

组件:

typescript: "^2.9.2",
apollo-boost: "^0.1.16",
react-apollo: "^2.1.11",

1 个答案:

答案 0 :(得分:0)

在{}

之后,您似乎缺少了逗号

尝试一下:

const ORGANISATION_QUERY = gql`
  query OrganisationQuery($id: Long!) {
    organisation(id: $id) {
      tasksEnabled
  }}`;

export class FeatureCardGraphQlComponent extends React.Component<{}, {}> {
public render() {
 return (
  <Query query={ORGANISATION_QUERY} variables={{ id: 1 }}>
    {({ data }) => {
      return <div>{data}</div>;
    }}
  </Query>
 );
}}