Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//react 0.14.7
saveModel() {
this.downloadFile(JSON.stringify(this.props.data, null, ' '));
},
downloadFile(contents) {
var newFileContent = new Blob([contents], {type: 'application/octet-binary'}),
downloadURL = window.URL.createObjectURL(newFileContent),
downloadLink = document.getElementById('file-download-link');
downloadLink.href = downloadURL;
downloadLink.download = this.props.data.type + '.json';
downloadLink.click();
// Free memory
setTimeout(function(){
window.URL.revokeObjectURL(downloadURL);
}, 1000);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.