react-native-view-snapshot

0.3.0 • Public • Published

Take snapshots of React Native views (and their children) and write to device storage.

Installation

% npm i --save react-native-view-snapshot

In XCode, in your project, add the .m and .h files to your Library folder.

Usage

For a full example, build the included ViewSnapshotExample project.

This library exposes a single method, saveSnapshotToPath. Example usage:

var ViewSnapshotter = require('react-native-view-snapshot');

ViewSnapshotter.saveSnapshotToPath(React.findNodeHandle(this.refs.someView), somePath, (error, successfulWrite) => {
    if (successfulWrite) {
        this.setState({catSaved: true})
    } else {
      console.log(error)
    }
});

Use cases

  • storing performant copies of complex static views, such as a set of layered PNGs with alpha transparency
  • sharing/uploading of snapshots specific view hierarchies, such as an image with a text overlay

TODO

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-view-snapshot

Weekly Downloads

8

Version

0.3.0

License

none

Last publish

Collaborators

  • jsierles