Skip to content

Commit 8be208e

Browse files
author
Jordan Hall
authoredSep 11, 2020
Merge pull request #105 from langleyfoxall/feature/on-error
Allow errors in AJAX requests issued by the AjaxDynamicDataTable to be captured
2 parents 48b5685 + 63f3a02 commit 8be208e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed
 

‎dist/AjaxDynamicDataTable.js

+11
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ var AjaxDynamicDataTable = /*#__PURE__*/function (_Component) {
221221
orderByDirection = _this$state2.orderByDirection;
222222
var _this$props2 = this.props,
223223
onLoad = _this$props2.onLoad,
224+
onError = _this$props2.onError,
224225
params = _this$props2.params,
225226
axios = _this$props2.axios;
226227
this.setState({
@@ -263,6 +264,12 @@ var AjaxDynamicDataTable = /*#__PURE__*/function (_Component) {
263264
_this2.setState(newState);
264265

265266
onLoad(newState);
267+
})["catch"](function (e) {
268+
_this2.setState({
269+
loading: false
270+
});
271+
272+
onError(e);
266273
});
267274
});
268275
}
@@ -313,6 +320,9 @@ AjaxDynamicDataTable.defaultProps = {
313320
onLoad: function onLoad() {
314321
return null;
315322
},
323+
onError: function onError() {
324+
return null;
325+
},
316326
loading: false,
317327
params: {},
318328
defaultOrderByField: null,
@@ -324,6 +334,7 @@ AjaxDynamicDataTable.defaultProps = {
324334
AjaxDynamicDataTable.propTypes = {
325335
apiUrl: _propTypes["default"].string,
326336
onLoad: _propTypes["default"].func,
337+
onError: _propTypes["default"].func,
327338
loading: _propTypes["default"].bool,
328339
params: _propTypes["default"].object,
329340
defaultOrderByField: _propTypes["default"].string,

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@langleyfoxall/react-dynamic-data-table",
3-
"version": "7.16.0",
3+
"version": "7.17.0",
44
"description": "Re-usable data table for React with sortable columns, pagination and more.",
55
"keywords": [
66
"react",

‎src/AjaxDynamicDataTable.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AjaxDynamicDataTable extends Component {
100100

101101
loadPage(page) {
102102
const {perPage, orderByField, orderByDirection} = this.state;
103-
const {onLoad, params, axios} = this.props;
103+
const {onLoad, onError, params, axios} = this.props;
104104

105105
this.setState(
106106
{ loading: true },
@@ -131,6 +131,12 @@ class AjaxDynamicDataTable extends Component {
131131

132132
this.setState(newState);
133133
onLoad(newState);
134+
135+
}).catch((e) => {
136+
137+
this.setState({ loading: false });
138+
onError(e);
139+
134140
});
135141
}
136142
);
@@ -159,6 +165,7 @@ class AjaxDynamicDataTable extends Component {
159165

160166
AjaxDynamicDataTable.defaultProps = {
161167
onLoad: () => null,
168+
onError: () => null,
162169
loading: false,
163170
params: {},
164171
defaultOrderByField: null,
@@ -172,6 +179,7 @@ AjaxDynamicDataTable.defaultProps = {
172179
AjaxDynamicDataTable.propTypes = {
173180
apiUrl: PropTypes.string,
174181
onLoad: PropTypes.func,
182+
onError: PropTypes.func,
175183
loading: PropTypes.bool,
176184
params: PropTypes.object,
177185
defaultOrderByField: PropTypes.string,

0 commit comments

Comments
 (0)
Please sign in to comment.