Socket
Socket
Sign inDemoInstall

@alliance-software-development/asd-media-react-native

Package Overview
Dependencies
0
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @alliance-software-development/asd-media-react-native

React Native Module for ASD Media built on top UploadCare API


Version published
Weekly downloads
1
decreased by-50%
Maintainers
5
Created
Weekly downloads
 

Readme

Source

asd-media-react-native

React Native Module for ASD Media built on top of UploadCare API

Prequisites

  • This library relies on react-native-image-picker. Please follow this guide to install in your project first. And react-native-blob-util. Please follow this guide to install.

Installation

npm install @alliance-software-development/asd-media-react-native

OR

yarn add @alliance-software-development/asd-media-react-native

Usage

import React from 'react';
import { View, Image, Button, StyleSheet } from 'react-native';
import { ASDMedia } from '@alliance-software-development/asd-media-react-native';

// ...

const App = () => {
  const asdMediaRef = React.useRef()
  const [selectedImage, setSelectedImage] = React.useState()

  const handleOnImageUpload = (data) => {
    alert(JSON.stringify(data));
  };

  const handleOnImageChange = (data) => {
    setSelectedImage(data.uri)
  };

  return (
    <View style={styles.container}>

      <View style={{ margin: 10 }}>
    <ASDMedia
      ref={asdMediaRef}
      publicKey="UPLOADCARE_PUBLIC_KEY"
      onImageUpload={handleOnImageUpload}
      onImageChange={handleOnImageChange}
    />
    </View>
    <Image source={{uri: selectedImage }} style={{width: 100, height: 100}}>
    <Button title="Upload" onPress={asdMediaRef.current?.handleUpload} />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
        flex: 1,
        flexDirection: "row",
        justifyContent: "center",
        alignItems: "center"
        }
})

Props

ASDMedia component accepts following props.

NameTypeDefaultIs Required
publicKeystring-Yes
onImageUploadFunc-Yes
onImageChangeFunc-No
buttonTextstringChoose a photoNo
buttonContainerStyle{}-No
buttonStyle{}-No
buttonTextStyle{}-No

Props Explanation

  • publicKey (String) - UploadCare public key of your project Doc here.
  • onImageUpload (?=Function) - Called upon success or failure of the upload session with { ...props }
  • onImageChange (?=Function) - Called when the image selection changes with { uri: imagepath }
  • buttonText (?String) - Button text, default is Choose a photo.
  • buttonContainerStyle (?Object) - Styling to be spread to the view wrapping the button Component.
  • buttonStyle (?Object) - Styling to be spread to the default button component style.
  • buttonTextStyle (?Object) - Button text styling

Keywords

FAQs

Last updated on 22 Feb 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc