New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-view-shot

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-view-shot

Capture a React Native view to an image

  • 4.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
248K
increased by16.62%
Maintainers
3
Weekly downloads
 
Created

What is react-native-view-shot?

The react-native-view-shot package allows you to capture snapshots of your React Native views and save them as images. This can be useful for various purposes such as creating screenshots, sharing content, or saving the state of a view.

What are react-native-view-shot's main functionalities?

Capture a view as an image

This feature allows you to capture a specific view and save it as an image. The code sample demonstrates how to use the ViewShot component to wrap a view and capture it when a button is pressed.

import React, { useRef } from 'react';
import { View, Button } from 'react-native';
import ViewShot from 'react-native-view-shot';

const App = () => {
  const viewShotRef = useRef(null);

  const captureView = () => {
    viewShotRef.current.capture().then(uri => {
      console.log('Image saved to', uri);
    });
  };

  return (
    <ViewShot ref={viewShotRef} options={{ format: 'jpg', quality: 0.9 }}>
      <View style={{ width: 200, height: 200, backgroundColor: 'red' }} />
      <Button title="Capture View" onPress={captureView} />
    </ViewShot>
  );
};

export default App;

Capture a view with specific options

This feature allows you to capture a view with specific options such as format and quality. The code sample demonstrates how to capture a view as a PNG image with 80% quality.

import React, { useRef } from 'react';
import { View, Button } from 'react-native';
import ViewShot from 'react-native-view-shot';

const App = () => {
  const viewShotRef = useRef(null);

  const captureView = () => {
    viewShotRef.current.capture({ format: 'png', quality: 0.8 }).then(uri => {
      console.log('Image saved to', uri);
    });
  };

  return (
    <ViewShot ref={viewShotRef} options={{ format: 'png', quality: 0.8 }}>
      <View style={{ width: 200, height: 200, backgroundColor: 'blue' }} />
      <Button title="Capture View" onPress={captureView} />
    </ViewShot>
  );
};

export default App;

Other packages similar to react-native-view-shot

Keywords

FAQs

Package last updated on 06 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc