yarn react-native-view-shot 2.0.0

latest releases: 4.0.0-alpha.3, 4.0.0-alpha.2, 4.0.0-alpha.1...
6 years ago

New ViewShot component, drop deprecated options, rename APIs

  • ViewShot is a React Component that you can use to snapshot anything, it is now the recommended way to use the library. It have different usages for different usecases, refer the README.

The simplest way to use it:

<ViewShot captureMode="mount" onCapture={uri => console.log("do something with ", uri)}>
  ...something to capture
</ViewShot>

ViewShot renders a View to wrap the children, this allows to hide complexity of using the library for Android (for some components you need to have a wrapping View collapsable={false} for the lib to work. Using ViewShot, you no longer have to worry about this)

But you can still use the library with the imperative API:

  • takeSnapshot(viewRef, options) function was renamed to captureRef(viewRef, options)
  • releaseCapture(uri) is a new function that accept an uri created with takeSnapshot and remove the tmpfile

Options changes

  • the result option "file" was renamed to "tmpfile"
  • the format option "jpeg" is dropped, simply use "jpg" (there used to be both supported)
  • the path option is no longer supported, see section below

Dropped path option and dirs constants

A feature used to allow to set an arbitrary file path. This has become tricky to maintain because all the edge cases and use-cases of file management so we have decided to drop it, making this library focusing more on solving snapshotting and not file system.

To migrate from this old feature, you have a few solutions:

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

NewReleases is sending notifications on new releases.