
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-camera
Advanced tools
The comprehensive camera module for React. Including photographs! (videos, and barcode scanning coming soon)
npm install react-camera
or
yarn add react-camera
import React, { Component } from 'react';
import Camera from 'react-camera';
export default class App extends Component {
constructor(props) {
super(props);
this.takePicture = this.takePicture.bind(this);
}
takePicture() {
this.camera.capture()
.then(blob => {
this.img.src = URL.createObjectURL(blob);
this.img.onload = () => { URL.revokeObjectURL(this.src); }
})
}
render() {
return (
<div style={style.container}>
<Camera
style={style.preview}
ref={(cam) => {
this.camera = cam;
}}
>
<div style={style.captureContainer} onClick={this.takePicture}>
<div style={style.captureButton} />
</div>
</Camera>
<img
style={style.captureImage}
ref={(img) => {
this.img = img;
}}
/>
</div>
);
}
}
const style = {
preview: {
position: 'relative',
},
captureContainer: {
display: 'flex',
position: 'absolute',
justifyContent: 'center',
zIndex: 1,
bottom: 0,
width: '100%'
},
captureButton: {
backgroundColor: '#fff',
borderRadius: '50%',
height: 56,
width: 56,
color: '#000',
margin: 20
},
captureImage: {
width: '100%',
}
};
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
FAQs
A Camera component for React.
The npm package react-camera receives a total of 189 weekly downloads. As such, react-camera popularity was classified as not popular.
We found that react-camera demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.