react-apollo
Advanced tools
Comparing version 2.5.1 to 2.5.2-rc.0
{ | ||
"name": "react-apollo", | ||
"version": "2.5.1", | ||
"version": "2.5.2-rc.0", | ||
"author": "opensource@apollographql.com", | ||
@@ -5,0 +5,0 @@ "description": "React data container for Apollo Client", |
@@ -68,3 +68,3 @@ import * as React from 'react'; | ||
componentWillUnmount(): void; | ||
componentDidUpdate(): void; | ||
componentDidUpdate(prevProps: QueryProps<TData, TVariables>): void; | ||
render(): React.ReactNode; | ||
@@ -79,3 +79,4 @@ private extractOptsFromProps; | ||
private updateCurrentData; | ||
private handleErrorOrCompleted; | ||
private getQueryResult; | ||
} |
29
Query.js
@@ -9,2 +9,3 @@ "use strict"; | ||
var component_utils_1 = require("./component-utils"); | ||
var lodash_isequal_1 = tslib_1.__importDefault(require("lodash.isequal")); | ||
var shallowEqual_1 = tslib_1.__importDefault(require("./utils/shallowEqual")); | ||
@@ -79,5 +80,17 @@ var ts_invariant_1 = require("ts-invariant"); | ||
_this.updateCurrentData = function () { | ||
_this.handleErrorOrCompleted(); | ||
if (_this.hasMounted) | ||
_this.forceUpdate(); | ||
}; | ||
_this.handleErrorOrCompleted = function () { | ||
var result = _this.queryObservable.currentResult(); | ||
var data = result.data, loading = result.loading, error = result.error; | ||
var _a = _this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
}; | ||
_this.getQueryResult = function () { | ||
@@ -197,13 +210,7 @@ var data = { data: Object.create(null) }; | ||
}; | ||
Query.prototype.componentDidUpdate = function () { | ||
var _a = this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted || onError) { | ||
var currentResult = this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, error = currentResult.error, data = currentResult.data; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
Query.prototype.componentDidUpdate = function (prevProps) { | ||
var isDiffRequest = !lodash_isequal_1.default(prevProps.query, this.props.query) || | ||
!lodash_isequal_1.default(prevProps.variables, this.props.variables); | ||
if (isDiffRequest) { | ||
this.handleErrorOrCompleted(); | ||
} | ||
@@ -210,0 +217,0 @@ }; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
var apolloClient = require('apollo-client'); | ||
var isEqual = _interopDefault(require('lodash.isequal')); | ||
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics')); | ||
@@ -253,5 +254,17 @@ | ||
_this.updateCurrentData = function () { | ||
_this.handleErrorOrCompleted(); | ||
if (_this.hasMounted) | ||
_this.forceUpdate(); | ||
}; | ||
_this.handleErrorOrCompleted = function () { | ||
var result = _this.queryObservable.currentResult(); | ||
var data = result.data, loading = result.loading, error = result.error; | ||
var _a = _this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
}; | ||
_this.getQueryResult = function () { | ||
@@ -371,13 +384,7 @@ var data = { data: Object.create(null) }; | ||
}; | ||
Query.prototype.componentDidUpdate = function () { | ||
var _a = this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted || onError) { | ||
var currentResult = this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, error = currentResult.error, data = currentResult.data; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
Query.prototype.componentDidUpdate = function (prevProps) { | ||
var isDiffRequest = !isEqual(prevProps.query, this.props.query) || | ||
!isEqual(prevProps.variables, this.props.variables); | ||
if (isDiffRequest) { | ||
this.handleErrorOrCompleted(); | ||
} | ||
@@ -384,0 +391,0 @@ }; |
@@ -5,2 +5,3 @@ import { object, func, node, string, bool, number, oneOfType, arrayOf, any } from 'prop-types'; | ||
import { ApolloError, NetworkStatus } from 'apollo-client'; | ||
import isEqual from 'lodash.isequal'; | ||
import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
@@ -247,5 +248,17 @@ | ||
_this.updateCurrentData = function () { | ||
_this.handleErrorOrCompleted(); | ||
if (_this.hasMounted) | ||
_this.forceUpdate(); | ||
}; | ||
_this.handleErrorOrCompleted = function () { | ||
var result = _this.queryObservable.currentResult(); | ||
var data = result.data, loading = result.loading, error = result.error; | ||
var _a = _this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
}; | ||
_this.getQueryResult = function () { | ||
@@ -365,13 +378,7 @@ var data = { data: Object.create(null) }; | ||
}; | ||
Query.prototype.componentDidUpdate = function () { | ||
var _a = this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted || onError) { | ||
var currentResult = this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, error = currentResult.error, data = currentResult.data; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
Query.prototype.componentDidUpdate = function (prevProps) { | ||
var isDiffRequest = !isEqual(prevProps.query, this.props.query) || | ||
!isEqual(prevProps.variables, this.props.variables); | ||
if (isDiffRequest) { | ||
this.handleErrorOrCompleted(); | ||
} | ||
@@ -378,0 +385,0 @@ }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('prop-types'), require('ts-invariant'), require('react'), require('apollo-client'), require('hoist-non-react-statics')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'prop-types', 'ts-invariant', 'react', 'apollo-client', 'hoist-non-react-statics'], factory) : | ||
(global = global || self, factory(global['react-apollo'] = {}, global.propTypes, global.tsInvariant, global.react, global.apolloClient, global.hoistNonReactStatics)); | ||
}(this, function (exports, propTypes, tsInvariant, react, apolloClient, hoistNonReactStatics) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('prop-types'), require('ts-invariant'), require('react'), require('apollo-client'), require('lodash.isequal'), require('hoist-non-react-statics')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'prop-types', 'ts-invariant', 'react', 'apollo-client', 'lodash.isequal', 'hoist-non-react-statics'], factory) : | ||
(global = global || self, factory(global['react-apollo'] = {}, global.propTypes, global.tsInvariant, global.react, global.apolloClient, global.isEqual, global.hoistNonReactStatics)); | ||
}(this, function (exports, propTypes, tsInvariant, react, apolloClient, isEqual, hoistNonReactStatics) { 'use strict'; | ||
isEqual = isEqual && isEqual.hasOwnProperty('default') ? isEqual['default'] : isEqual; | ||
hoistNonReactStatics = hoistNonReactStatics && hoistNonReactStatics.hasOwnProperty('default') ? hoistNonReactStatics['default'] : hoistNonReactStatics; | ||
@@ -248,5 +249,17 @@ | ||
_this.updateCurrentData = function () { | ||
_this.handleErrorOrCompleted(); | ||
if (_this.hasMounted) | ||
_this.forceUpdate(); | ||
}; | ||
_this.handleErrorOrCompleted = function () { | ||
var result = _this.queryObservable.currentResult(); | ||
var data = result.data, loading = result.loading, error = result.error; | ||
var _a = _this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
}; | ||
_this.getQueryResult = function () { | ||
@@ -366,13 +379,7 @@ var data = { data: Object.create(null) }; | ||
}; | ||
Query.prototype.componentDidUpdate = function () { | ||
var _a = this.props, onCompleted = _a.onCompleted, onError = _a.onError; | ||
if (onCompleted || onError) { | ||
var currentResult = this.queryObservable.currentResult(); | ||
var loading = currentResult.loading, error = currentResult.error, data = currentResult.data; | ||
if (onCompleted && !loading && !error) { | ||
onCompleted(data); | ||
} | ||
else if (onError && !loading && error) { | ||
onError(error); | ||
} | ||
Query.prototype.componentDidUpdate = function (prevProps) { | ||
var isDiffRequest = !isEqual(prevProps.query, this.props.query) || | ||
!isEqual(prevProps.variables, this.props.variables); | ||
if (isDiffRequest) { | ||
this.handleErrorOrCompleted(); | ||
} | ||
@@ -379,0 +386,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
414526
5390
2
80
2