Skip to content

Commit

Permalink
Provide shouldInvalidatePreviousData prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcready authored Mar 21, 2019
1 parent 6f6b6ed commit 4f57d50
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class Query<TData = any, TVariables = OperationVariables> extends
static propTypes = {
client: PropTypes.object,
children: PropTypes.func.isRequired,
shouldInvalidatePreviousData: PropTypes.func,
fetchPolicy: PropTypes.string,
notifyOnNetworkStatusChange: PropTypes.bool,
onCompleted: PropTypes.func,
Expand Down Expand Up @@ -202,6 +203,10 @@ export default class Query<TData = any, TVariables = OperationVariables> extends
this.queryObservable = null;
this.previousData = {};
this.updateQuery(nextProps);
} else if (typeof nextProps.shouldInvalidatePreviousData === 'function') {
if (nextProps.shouldInvalidatePreviousData(nextProps.variables, this.props.variables)) {
this.previousData = {};
}
}

if (this.props.query !== nextProps.query) {
Expand Down

0 comments on commit 4f57d50

Please sign in to comment.