S
SolidJS2mo ago
nut

How to deal with component unmounting while fetch in progress?

Is this a problem? For example, if you do a fetch request in a component, the user leaves the page, and then the request finishes. It will cause state updates, but the component is already unmounted. So it could cause memory leaks maybe? Does anyone bother dealing with this? I see two possible solutions: 1. Use AbortController and cancel the requests in the onCleanup function 2. Have an isMounted boolean flag that is set to true initially, set to false in the onCleanUp handler, and then after requests come back, do something like if (!isMounted) { return: } 3. Do nothing. Doesn't seem to be causing issues at the moment. Thoughts?
0 Replies
No replies yetBe the first to reply to this messageJoin