I went through several similar questions but wasn't able to get anywhere in solving this. I was following along with a tutorial from 2019 and I'm having trouble figuring out the right way to do the same thing in 2020. Here's the line I'm getting an error on:
ERROR: 'HotelsQuery' only refers to a type, but is being used as a namespace here.ts(2702)
type IHotelsProps = HotelsQuery.Props<IHotelsBaseProps> & RouteComponentProps;
I'm passing HotelsQuery from my generatedModels file, defined as:
export type HotelsQuery = (
{ __typename?: 'Query' }
& { hotels?: Maybe<(
{ __typename?: 'HotelTypeConnection' }
& { edges: Array<Maybe<(
{ __typename?: 'HotelTypeEdge' }
& { node?: Maybe<(
{ __typename?: 'HotelType' }
& Pick<HotelType, 'id' | 'title' | 'body'>
)> }
)>> }
)> }
);
And the class it's being passed to:
class Hotels extends React.Component<IHotelsProps, IHotelsState> {
constructor(props: IHotelsProps) {
super(props);
const query = queryString.parse(props.location.search);
this.state = {
searchQuery: query && query.search
? query.search.toString() : undefined
};
}
public render() {
const { searchQuery } = this.state;
const { data } = this.props;
return (
<Row>
<Col span={12} offset={6}>
<Divider>Add Hotel</Divider>
<Divider>Hotels</Divider>
<Input.Search
placeholder="Search..."
enterButton="Search"
defaultValue={searchQuery}
onChange={this.handleSearchQueryChange}
onSearch={this.handleSearch}
/>
{data!.loading ? (
<Spin style={{ marginTop: 16, display: 'block' }} /> )
: (
<div>
{data!.notes!.edges.map(edge => (
<Card
key={edge!.node!.id}
style={{ marginTop: 16 }}
actions={[
<Icon
type="delete"
key={edge!.node!.id}
onClick={() => this.handleDeleteHotel(edge!.node!.id)}
/>
]}
>
<Card.Meta
title={edge!.node!.title}
description={edge!.node!.body}
/>
</Card>
))}
</div>
)}
</Col>
</Row>
);
}