First render of image (on mobile) is broken, on refresh rendered image is correct
See original GitHub issueThere is an issue I have surfaced on mobile devices - particularly using Safari where the first render of the image is completely broken, formatting issues, font issues etc.
On refresh these are resolved and the image is correct.
Here is my code:
htmlToImage
.toJpeg(node, {
backgroundColor: "#621934",
width: "700",
})
.then(function (dataUrl) {
var img = new Image();
img.src = dataUrl;
img.className = "rendered-img";
final.appendChild(img);
downloadImage.addEventListener("click", () => {
var link = document.createElement("a");
link.download = "img.jpeg";
link.href = dataUrl;
link.click();
});
})
.catch(function (error) {
console.error("oops, something went wrong!", error);
});
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Force React to reload an image file? - Stack Overflow
Can I use this to re-render the image? I tried this.forceUpdate() but it doesn't work. reactjs.
Read more >React Fallback for Broken Images Strategy | by Dani Shulman
Let's get back to broken images. The most basic approach would be to use the onError event and replace an image that failed...
Read more >How to handle loading of images that may not exist?
So the first thing that you can do to counter the broken image problem is to periodically check all images for sanity.
Read more >You're Doing Image Rendering WRONG in Next.js! - YouTube
Want coding problems (with solutions!) delivered to your inbox daily!?Sign Up Here: https://www.papareact.com/universityofcode Join the ...
Read more >7 Reasons Why Images Are Not Loading on Your Website
Upload those images, refresh your web page, and it should immediately display the files as expected. You can also try to delete the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No I haven’t found a fix, unfortunately. There doesn’t seem to be much support for this package anymore either so I can’t see it being fixed anytime soon.
So i was able to solve this using html2canvas this one
here’s what I’m doing
Hope this helps