Skip to content

Instantly share code, notes, and snippets.

@timoxley

timoxley/test.js Secret

Created October 15, 2018 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timoxley/522d953c3fed6184f2da9bed272bfd9d to your computer and use it in GitHub Desktop.
Save timoxley/522d953c3fed6184f2da9bed272bfd9d to your computer and use it in GitHub Desktop.
class extends React.Component {
componentDidMount() {
this.controller = new window.AbortController()
const { signal } = this.controller
fetch('/one', { signal }).then(one => this.setState({ one }))
fetch('/two', { signal }).then(two => this.setState({ two }))
}
componentWillUnmount() {
this.controller.signal.abort()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment