yarn react-native-view-shot 5.0.0
v5.0.0

latest releases: 5.1.0, 5.0.1
one month ago

First stable release of the 5.x line. This is a major version bump covering the New Architecture migration, a project-wide cleanup, and a long list of cross-platform fixes accumulated since v4.0.3. If you're upgrading from 4.x, please read the Breaking changes section below.

Highlights

  • New Architecture (Fabric + TurboModules) supported across iOS, Android, Web, Windows.
  • React Native peer dep bumped to >=0.76.0. Tested up to 0.84.1.
  • JS/TS layer migrated to TypeScript (src/ is now .ts/.tsx).
  • Android capture path hardened: view.draw() and view resolution now run on the UIManager queue with a hard timeout, cancellation, exception propagation, and a CAS-based bitmap pool handoff so canvas-backing bitmaps cannot be recycled mid-draw.
  • iOS updated for RCTScrollView removal in RN 0.84 (runtime UIScrollView detection covering both Paper and Fabric), plus a Privacy Manifest.
  • Web got several fixes around captureRef, JPG output, releaseCapture, and CORS image handling.
  • Example apps rebooted with 11 organized test screens; new Expo example added; new Detox + Playwright E2E coverage; CI now builds downloadable example APK.

Breaking changes

  • Minimum React Native is 0.76.0. Lower versions are no longer supported.
  • The library is now built from TypeScript. The public API is unchanged but generated .d.ts files now ship alongside lib/ (the package.json main still points to lib/index.js, the react-native field points to src/index.tsx).
  • Internal RNViewShot.web.js was renamed to RNViewShot.web.ts. Metro and webpack still resolve *.web.ts automatically.
  • The Android module exposes a TurboModule spec under src/specs/NativeRNViewShot.ts. The runtime detects old vs. new arch via global.__turboModuleProxy so consumers do not need to choose explicitly.

What changed

New Architecture / RN 0.84

  • #580 Stack update: RN 0.81.4 + Fabric + TurboModules, TypeScript migration, example reboot, CI bootstrapped.
  • #587 Upgrade example to React Native 0.84.1 and fix the removal of RCTScrollView on iOS by switching to runtime UIScrollView detection (subview walk + respondsToSelector:) that works under both Paper and Fabric.
  • #621 Restore Android autolinking and runtime on RN 0.84 with the new arch enabled.
  • #620 Fix react-native.config.js so the library is correctly linked on Android.

Android

  • #628 (refactor(android)) UI-thread-safe view capture with hardened bitmap lifecycle:
    • view.draw() now runs on the UIManager queue instead of the capture executor.
    • runOnUiThreadBlocking posts work to the main looper with a hard 5s timeout (UiThreadBlockTimeoutException) so a stuck UI thread cannot hang capture forever.
    • State machine (STATE_QUEUED/RUNNING/DONE) with CAS between caller (timeout) and runnable (entry) so exactly one side owns cleanup.
    • Bitmap recycling split between caller and UI runnable via AtomicReference<Bitmap> + getAndSet(null) so the canvas-backing bitmap cannot be returned to the pool while view.draw() is still drawing into it.
    • handler.post() return value checked, Throwable thrown inside the UI runnable is captured and rethrown on the caller thread (surfaces as promise.reject(...) instead of crashing the UI thread).
    • Layer-marking scaffolding for translucent ViewGroup subtrees (kept inert in practice, see PR for context).
  • #630 (fix(android)) Resolve view on the UIManager queue before posting capture work to the executor (cherry-pick of #556 by @wfern), with a try/catch so currentActivity == null (app backgrounded) or a throw inside resolveView rejects the promise instead of crashing the UIManager queue.

iOS

  • #587 ScrollView capture works on RN 0.84 again: detects UIScrollView via subview walk and respondsToSelector:@selector(scrollView) so both RCTScrollViewComponentView (Fabric) and legacy RCTScrollView (Paper) are covered with no compile-time __has_include branches.
  • #600 Add iOS Privacy Manifest (PrivacyInfo.xcprivacy).

Web

  • #599 Fix captureRef crash on web by skipping findNodeHandle (not supported).
  • #601 Enable useCORS for html2canvas to fix cross-origin image capture.
  • #602 Fix JPG format and base64 preview.
  • #604 Fix releaseCapture crash on web (now a no-op since there are no temp files to clean up) and add a ViewShot component example.

Examples, tests, CI

  • #580 Example app rebooted with 11 organized test cases (Basic, Media, Advanced).
  • #603 Add unit tests for the JS/TS layer.
  • #605 Add a dedicated Expo example app for testing with Expo + the New Architecture.
  • #617 New CI workflow: build a downloadable example APK on every PR.
  • #627 New "RENDERING CORRECTNESS" test card screen for visual regression checks across borderRadius/overflow:hidden, transforms, z-index, scrolled ScrollView, padding+bg+border, nested opacity, and Skia comparator.
  • Detox iOS E2E + Playwright web E2E running on CI.
  • #629 Refresh example apps lockfiles to in-range latest.

Docs

Dependency updates

Numerous dependabot bumps in example/example-web/example-windows/example-expo (lodash, minimatch, fast-xml-parser, node-forge, picomatch, handlebars, brace-expansion, follow-redirects, flatted, terser-webpack-plugin, copy-webpack-plugin, serve, serialize-javascript). The library itself has no new runtime dependencies.

Closed PRs of note (superseded or already-on-master)

These were closed during this release cycle in favor of the consolidated work above:

  • #531 (UiThreadUtil) superseded by the surgical UI-thread moves in #628 + #630.
  • #540 (manual recursion view-cuts-off rewrite) superseded by the view.draw()-preserving approach.
  • #563 (web releaseCapture throwing) addressed on master.
  • #584 (RN 0.84 ScrollView iOS) addressed on master via #587.

Contributors

Thanks to everyone who contributed to this release:

Full changelog: v4.0.3...v5.0.0

Don't miss a new react-native-view-shot release

NewReleases is sending notifications on new releases.