mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 05:11:19 +00:00
Remove AbortController usage (#3739)
GitOrigin-RevId: 662589bc8da8133036e4e9211098a9c5545c8edf
This commit is contained in:
parent
3c2351c22f
commit
c3a6ac320b
2 changed files with 3 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
|||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import AbortController from 'abort-controller'
|
||||
import WordCountModalContent from './word-count-modal-content'
|
||||
import { fetchWordCount } from '../utils/api'
|
||||
|
||||
|
@ -8,7 +7,6 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(false)
|
||||
const [data, setData] = useState()
|
||||
const [abortController, setAbortController] = useState(new AbortController())
|
||||
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
|
@ -19,12 +17,7 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|||
setError(false)
|
||||
setLoading(true)
|
||||
|
||||
const _abortController = new AbortController()
|
||||
setAbortController(_abortController)
|
||||
|
||||
fetchWordCount(projectId, clsiServerId, {
|
||||
signal: _abortController.signal
|
||||
})
|
||||
fetchWordCount(projectId, clsiServerId)
|
||||
.then(data => {
|
||||
setData(data.texcount)
|
||||
})
|
||||
|
@ -36,23 +29,14 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|||
.finally(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
|
||||
return () => {
|
||||
_abortController.abort()
|
||||
}
|
||||
}, [show, projectId, clsiServerId])
|
||||
|
||||
const abortAndHide = useCallback(() => {
|
||||
abortController.abort()
|
||||
handleHide()
|
||||
}, [abortController, handleHide])
|
||||
|
||||
return (
|
||||
<WordCountModalContent
|
||||
data={data}
|
||||
error={error}
|
||||
show={show}
|
||||
handleHide={abortAndHide}
|
||||
handleHide={handleHide}
|
||||
loading={loading}
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -166,7 +166,6 @@
|
|||
"@storybook/react": "^6.1.10",
|
||||
"@testing-library/dom": "^7.29.4",
|
||||
"@testing-library/react": "^11.2.3",
|
||||
"abort-controller": "^3.0.0",
|
||||
"acorn": "^7.1.1",
|
||||
"acorn-walk": "^7.1.1",
|
||||
"angular-mocks": "~1.8.0",
|
||||
|
|
Loading…
Reference in a new issue