Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Added prop-types validation to unchecked components. #1587

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### vNext

* Added `prop-types` validation to the `<Query />`, `<Subscription />` and `<ApolloConsumer />` component [#1587](https://github.com/apollographql/react-apollo/pull/1587)

### 2.1.0-beta.0

* Beta release of all 2.1 features!
Expand Down
4 changes: 4 additions & 0 deletions src/ApolloConsumer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ ApolloConsumer.contextTypes = {
client: PropTypes.object.isRequired,
};

ApolloConsumer.propTypes = {
children: PropTypes.func.isRequired,
};

export default ApolloConsumer;
10 changes: 10 additions & 0 deletions src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class Query<TData = any, TVariables = OperationVariables> extends React.Componen
static contextTypes = {
client: PropTypes.object.isRequired,
};

static propTypes = {
children: PropTypes.func.isRequired,
fetchPolicy: PropTypes.string,
notifyOnNetworkStatusChange: PropTypes.bool,
pollInterval: PropTypes.number,
query: PropTypes.object.isRequired,
variables: PropTypes.object,
ssr: PropTypes.bool,
};

state: QueryState<TData>;
private client: ApolloClient<any>;
Expand Down
6 changes: 6 additions & 0 deletions src/Subscriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class Subscription<TData = any> extends React.Component<
client: PropTypes.object.isRequired,
};

static propTypes = {
query: PropTypes.object.isRequired,
variables: PropTypes.object,
children: PropTypes.func.isRequired,
};

private client: ApolloClient<any>;
private queryObservable: Observable<any>;
private querySubscription: ZenObservable.Subscription;
Expand Down