seekshiva / react-native-remote-svg

Adds support for loading svg images in React Native
MIT License
184 stars 71 forks source link

Cancel Fetch on Unmount (and Other Updates) #21

Closed RobertFischer closed 2 years ago

RobertFischer commented 5 years ago

This PR does the following things:

  1. Add in PropTypes so that we give our users feedback on whether or not they are passing the correct parameters. (They can remove them in production using babel-plugin-transform-react-remove-prop-types.)
  2. Capture the promise that is performing the fetch, so that we can cancel it on unmount. This saves a memory leak and a warning message whenever someone navigates away before the fetch resolves.
  3. Switch to Bluebird so that we have the promise.cancel() functionality required in #3.
  4. Chain the promises, so multiple rapid changes would still all be cancelled on unmount.
  5. Move off of deprecated React.Component methods to their contemporary alternatives.
RobertFischer commented 5 years ago

If you merge both this and #20, then you'll want to pull from my rcf/ensure-fetch-cancelled-with-debug branch instead.

seekshiva commented 2 years ago

fetch abort has been implemented using AbortController and released in 2.0.10.