Skip to content

Instantly share code, notes, and snippets.

@J-Cake
Created April 7, 2019 03:29
Show Gist options
  • Save J-Cake/a9a4e12cfe5487feaa1a3a8cd73cafac to your computer and use it in GitHub Desktop.
Save J-Cake/a9a4e12cfe5487feaa1a3a8cd73cafac to your computer and use it in GitHub Desktop.
const that = this; // lol I know
const download = <DownloadComp onComplete={() => this.next()}
onStatusChange={async function (status) {
if (status !== 2 && status !== 3) {
console.log('unaffected');
} else {
console.log(this);
that.setState(prev => ({
inactiveDownloads: [...(prev.inactiveDownloads || []), download]
}));
console.log(that.state.activeDownloads, that.state.inactiveDownloads);
}
}}
alert={box => this.alert(box)}
id={this.state.activeDownloads.length + 1}
remove={() => this.setState({
download: [
this.state.activeDownloads.splice(this.state.activeDownloads.indexOf(this), 1)
]
})}
updateTaskBarProgress={(index, progress) => this.updateTaskBarValue(index, progress)}
key={Date.now()} url={this.state.downloadURL}
customHeaders={this.state.customHeaders}
name={this.state.downloadName}
ref={ref => this.shouldStart(ref)}
/>;
await this.setState(prev => ({
activeDownloads: [...prev.activeDownloads, download]
}));
@jjantschulev
Copy link

what needs to happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment