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

react-camera

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-camera

A Camera component for React.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
183
increased by28.87%
Maintainers
1
Weekly downloads
 
Created
Source

React Camera Travis status build npm version

The comprehensive camera module for React. Including photographs! (videos, and barcode scanning coming soon)

Getting started

npm --save react-camera

Usage

import React, { Component } from 'react';
import Camera from 'react-camera';

class App extends Component {

  constructor(props) {
    super(props);
    this.takePicture = this.takePicture.bind(this);
  }

  takePicture() {
    const { img } = this.refs;
    this.refs.camera.capture()
    .then(blob => {
      img.src = URL.createObjectURL(blob);
      img.onload = () => { URL.revokeObjectURL(this.src); }
    })
  }

  render() {
    return (
      <div style={style.container}>
        <Camera
          style={style.preview}
          ref="camera"
        >
          <div style={style.capture} onClick={this.takePicture}>[TAKE A PICTURE]</div>
        </Camera>
        <img ref="img" />
      </div>
    );
  }
}

export default App;

const style = {
  preview: {
    flex: 1,
  },
  container: {
    flex: 1,
    flexDirection: 'row',
  },
  capture: {
    flex: 0,
    backgroundColor: '#fff',
    borderRadius: 5,
    color: '#000',
    padding: 10,
    margin: 40
  },
};

Component instance methods

You can access component methods by adding a ref (ie. ref="camera") prop to your element, then you can use this.refs.camera.capture(cb), etc. inside your component.

capture(): Promise

Keywords

FAQs

Package last updated on 02 Sep 2017

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