What’s the proper way to capture a screenshot from a React Three Fiber canvas just before unmounting the component? I need to take a high-quality snapshot of the 3D scene and upload it to AWS S3, but I’m encountering WebGL context loss issues when trying to capture the image during component unmount. Is there a recommended pattern or lifecycle hook to ensure the screenshot is taken while the WebGL context is still valid?
I understand that I could take the screenshot at any point during the component’s lifecycle, not necessarily at unmount time, but I have specific reasons for needing to capture the final state just before the component is removed from the DOM