Skip to content

Commit 50b3fbc

Browse files
committed
fetchWithTimeout was crashing /diff in React 18 rendering mode
Everything works correctly when we use the standard `fetch()`.
1 parent b649698 commit 50b3fbc

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

src/components/ymd-timestamp-header.jsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import '../css/diff-container.css';
4-
import {
5-
fetchWithTimeout, getUTCDateFormat, getShortUTCDateFormat, jsonResponse
6-
} from '../js/utils.js';
4+
import { getUTCDateFormat, getShortUTCDateFormat, jsonResponse } from '../js/utils.js';
75
import Loading from './loading.jsx';
86
import isNil from 'lodash/isNil';
97
import isEmpty from 'lodash/isEmpty';
@@ -43,7 +41,6 @@ export default class YmdTimestampHeader extends React.Component {
4341
constructor (props) {
4442
super(props);
4543
const { timestampA, timestampB } = this.props;
46-
this._abortController = new window.AbortController();
4744

4845
this.timestampSelectLeft = React.createRef();
4946
this.timestampSelectRight = React.createRef();
@@ -71,10 +68,6 @@ export default class YmdTimestampHeader extends React.Component {
7168
}
7269
}
7370

74-
componentWillUnmount () {
75-
this._abortController.abort();
76-
}
77-
7871
_handleRightTimestampChange = (event) => {
7972
this.setState({ timestampB: event.target.value });
8073
this._updateSnaps('right');
@@ -217,7 +210,7 @@ export default class YmdTimestampHeader extends React.Component {
217210
requestUrl.searchParams.append('date', year1 + month1);
218211
requestUrl.searchParams.append('digest', 1);
219212

220-
return fetchWithTimeout(requestUrl, { signal: this._abortController.signal })
213+
return fetch(requestUrl)
221214
.then(jsonResponse)
222215
.then(data => data['items'])
223216
.then(data => data.map(item => [year1 + month1 + String(item[0]).padStart(8, '0'), item[2]]))
@@ -300,7 +293,7 @@ export default class YmdTimestampHeader extends React.Component {
300293
url.searchParams.append('url', this.props.url);
301294
url.searchParams.append('collection', 'web');
302295
url.searchParams.append('output', 'json');
303-
fetchWithTimeout(url, { signal: this._abortController.signal })
296+
fetch(url)
304297
.then(jsonResponse)
305298
.then((data) => {
306299
if (data) {

0 commit comments

Comments
 (0)