在组件销毁时,执行useRequest生成的runAsync方法,不会触发onSuccess方法等,貌似任务被挂起
- Dominant language
- TypeScript
- Stars
- 15k
- Forks
- 2.8k
- Avg merge
- 15h 7m
- Merged PRs (30d)
- 2
Description
```javascript
const { runAsync: runEditBeam } = useRequest(
params => {
return beamSetData?.treatmentTechnique === TreatmentTechnique.PencilBeamScanning
? editBeam(params)
: editUSBeam(params)
},
{
manual: true,
ready: !isNil(beamSetData),
onSuccess: () => {
dispatch(versionActions.setVersion())
},
},
)
```
runEditBeam方法会透穿给子组件。
在子组件销毁(当前组件也会)时,执行runEditBeam方法,会出现onSuccess不执行的异常。
同时,子组件中的try runEditBeam catch也被吃掉。
Contributor guide
Research direction
Start with the useRequest runAsync entry point and reproduce the runEditBeam call while the child and current components are being destroyed. Trace what happens to the promise, onSuccess callback, and the child's try/catch during unmount. Done means the intended behavior for these callbacks and promise errors is established and the reported lifecycle case no longer loses them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100