Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.
How to download fetch response in react as file Ask Question. Asked 5 years, 10 months ago. Active 4 months ago. Viewed k times. Here is the code in actions. What should I do in the reducer? Improve this question. Rafael K.
Add a comment. Active Oldest Votes. I have a React component called FileDownload. All this component does is render a hidden form and then, inside componentDidMount , immediately submit the form and call it's onDownloadComplete prop. Widget has corresponding action and store files. Widget imports FileDownload. Widget has two methods related to the download: handleDownload and handleDownloadComplete.
Widget store has a property called downloadPath. It's set to null by default. When it's value is set to null , there is no file download in progress and the Widget component does not render the FileDownload component. The store saves the downloadPath and emits a change event.
Since there is now a downloadPath , Widget will render FileDownload passing in the necessary props including downloadPath as well as the handleDownloadComplete method as the value for onDownloadComplete. However, this time downloadPath is set to null. The store saves the downloadPath as null and emits a change event.
Since there is no longer a downloadPath the FileDownload component is not rendered in Widget and the world is a happy place. Improve this answer. I have a React component called FileDownload. All this component does is render a hidden form and then, inside componentDidMount , immediately submit the form and call it's onDownloadComplete prop.
Widget has corresponding action and store files. Widget imports FileDownload. Widget has two methods related to the download: handleDownload and handleDownloadComplete. Widget store has a property called downloadPath. It's set to null by default. When it's value is set to null , there is no file download in progress and the Widget component does not render the FileDownload component. The store saves the downloadPath and emits a change event.
Since there is now a downloadPath , Widget will render FileDownload passing in the necessary props including downloadPath as well as the handleDownloadComplete method as the value for onDownloadComplete.
However, this time downloadPath is set to null. Harshith Reddy 2 2 silver badges 10 10 bronze badges. Sajeetharan Sajeetharan k 55 55 gold badges silver badges bronze badges.
Moff I do not see it being deprecated on Mozzila developer. Where do you get that information from? My solution to start a download. I used this in an NgRX Effect. Deitsch Deitsch 1, 5 5 silver badges 22 22 bronze badges. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
Podcast An oral history of Stack Overflow — told by its founding team.
0コメント