-
-
Save timoxley/522d953c3fed6184f2da9bed272bfd9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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