Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-simple-image-cropper

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-simple-image-cropper

## Show Case

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55
increased by30.95%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-simple-image-cropper

Show Case

/demo.gif

Getting Started

Installation

npm i react-native-simple-image-cropper --save

or

yarn add react-native-simple-image-cropper

Usage

import React from 'react';
import { View, Image, Button, StyleSheet } from 'react-native';
import ImageCropper from 'react-native-simple-image-cropper';

const IMAGE = 'https://picsum.photos/900/500';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
});

class App extends React.Component {
	state = {
    cropperParams: {},
    croppedImage: '',
  };

  setCropperParams = cropperParams => {
    this.setState(prevState => ({
      ...prevState,
      cropperParams,
    }));
  };
  
  handlePress = async () => {
    const { cropperParams } = this.state;
    const cropSize = {
      width: 200,
      height: 200,
    };

    try {
      const result = await ImageCropper.crop({
        ...cropperParams,
        imageUri: IMAGE,
        cropSize,
      });
      this.setState(prevState => ({
        ...prevState,
        croppedImage: result,
      }));
    } catch (error) {
      console.log(error);
    }
  };
  
  render() {
    const { croppedImage } = this.state;
    
    return (
      <View style={styles.container}>
        <ImageCropper imageUri={IMAGE} setCropperParams={this.setCropperParams} />
        <Button onPress={this.handleCropPress} title="Crop Image" color="blue" />
        {croppedImage ? (
          <Image style={{ width: 100, height: 100 }} source={{ uri: croppedImage }} />
        ) : null}
      </View>
    );
	}
}

Credits

Based from react-native-image-zoom.

License

MIT

FAQs

Package last updated on 25 Mar 2019

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