remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.09k stars 10.31k forks source link

[Bug]: undefined is not an object (evaluating ' request.signal.aborted ') #11907

Open yxqme opened 2 months ago

yxqme commented 2 months ago

What version of React Router are you using?

react-router-dom 6.26.1

Steps to Reproduce

Use lazy loading for the page.

lazy: () => import("./pages"),

In browsers that do not support request.signal For example, iOS phone version 13.6. The following code will throw an error undefined is not an object (evaluating ' request.signal.aborted ')

if (request.signal.aborted) {
    // Handle aborted request
}

Can it be changed to the code below to improve compatibility?

// ... existing code ...
if (request.signal && request.signal.aborted) {
    // Handle aborted request
}
// ... existing code ...

Expected Behavior

Do not throw an error.

Actual Behavior

Threw an error.

BrianWoolfolk commented 1 month ago

It's there a PR about this? I think request.signal?.aborted would be simpler. Being such a small fix, I could send a PR in a moment