Fix releaseCapture crash on web and add ViewShot component example#604
Merged
Fix releaseCapture crash on web and add ViewShot component example#604
Conversation
Adds example-web screen testing the ViewShot component (as opposed to captureRef with a plain View ref). Covers both manual capture via ref.capture() and automatic capture via captureMode="mount". This validates that the ViewShot component works on web, addressing the "Element is not attached to a Document" report in #564. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
releaseCapture on web was throwing "Tmpfile is not implemented" which crashed the app when ViewShot.onCapture tried to release the previous capture URI. Changed to a no-op since there are no tmp files on web. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
|
Playwright shall regen new screenshots that will need to be amended in another commit |
There was a problem hiding this comment.
Pull request overview
This PR improves the web implementation of react-native-view-shot by making releaseCapture safe on web and expands the example-web app with a new “ViewShot Component” screen plus Playwright coverage for component-based captures.
Changes:
- Change
releaseCaptureon web from throwing to a no-op, and update unit tests accordingly. - Add a new
ViewShotComponentScreento the web example and wire it into navigation/types. - Add Playwright E2E tests (and one reference snapshot) covering
ViewShotcomponentref.capture()andcaptureMode="mount".
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/RNViewShot.web.ts | Makes releaseCapture a no-op on web to avoid runtime errors. |
| src/tests/RNViewShot.web.test.ts | Updates unit test to assert releaseCapture does not throw. |
| example-web/src/types.ts | Adds the ViewShotComponent route type. |
| example-web/src/screens/ViewShotComponentScreen.tsx | New example screen demonstrating component capture + mount auto-capture. |
| example-web/src/screens/HomeScreen.tsx | Adds the new test case entry to the home list. |
| example-web/src/App.tsx | Wires navigation to the new screen. |
| example-web/e2e/viewshot.spec.ts | Adds E2E tests and a visual snapshot for the new screen. |
| example-web/e2e/snapshots/reference/...viewshot-component-manual...png | Adds the new reference snapshot (currently only for darwin). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+248
to
+257
| // Visual snapshot | ||
| await expect(previewImage).toHaveScreenshot( | ||
| "viewshot-component-manual.png", | ||
| { | ||
| threshold: 0.2, | ||
| maxDiffPixels: 1000, | ||
| scale: "css", | ||
| animations: "disabled", | ||
| }, | ||
| ); |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
releaseCaptureon web was throwing"Tmpfile is not implemented"which crashed the app whenViewShot.onCapturetried to release the previous capture URI on a second capture. Changed to a no-op since there are no tmp files on web.ViewShotComponentScreento example-web that tests theViewShotcomponent (as opposed tocaptureRefwith a plainViewref). Covers both manual capture viaref.capture()and automatic capture viacaptureMode="mount".Ref #564
Test plan
npm test— 43 unit tests pass (updated releaseCapture test)🤖 Generated with Claude Code