遇到此打字稿错误。尝试使用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",
答案 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>
);
}}