'How to prevent reloading of iframe in reactjs?
There is an api from which I get html document contents, currently I am taking data in chunks and setting to state and there is iframe whose "srcDoc" attribute is taking that value from state. What I want to do is prevent reloading of iframe because each time "srcDoc" is set iframe scroll is taken to top and it reloads. Here's code :
const stream = new Promise(() => {
axios({
url: `http://54.90.50.223/api/mainapi/Documents/GetHTML`,
method: "GET",
onDownloadProgress: (progressEvent) => {
const dataChunk = progressEvent.currentTarget.response;
console.log(dataChunk);
str += dataChunk;
this.setState({ srcDoc: str });
},
}).then(({ data }) => Promise.resolve(data));
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
