michiganhackers / mh-web-new

For the new Michigan Hackers website!
http://michhackers.com
GNU Affero General Public License v3.0
7 stars 2 forks source link

Cancelable fetch for Calendar #84

Open KindaOK opened 2 years ago

KindaOK commented 2 years ago

When the fetch runs on the calendar, and the user navigates away from the component before the fetch completes. We end up with it trying to setState on an unmounted component, which is bad. The options are kinda nasty with one being that we have a variable isMounted, or something of the sort. Cancelled promises also don't really exist natively, so we either have to add some dependencies (rxjs I would be fine with actually, but I think it's heavy and I would rather not add more dependencies if possible), or copy-paste a bunch of code to poylfill it. Hateful either way.

KindaOK commented 2 years ago

https://developer.mozilla.org/en-US/docs/Web/API/AbortController Already compatible with everything except IE, and I don't think that polyfill will kill us.