Snapshot a React Native view and save it to an image
MIT License
Bot releases are visible (Hide)
Maintenance release supporting latest version of iOS / Android and react native.
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 tmpfileresult
option "file" was renamed to "tmpfile"format
option "jpeg" is dropped, simply use "jpg" (there used to be both supported)path
option is no longer supported, see section belowpath
option and dirs
constantsA 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:
https://github.com/gre/react-native-view-shot/pull/8 [Android] Fixes the extension of the image
result
to specify the output format (save to a file / yield a base64)