Installations
npm install react-native-camera-hooks
Score
74.9
Supply Chain
98.9
Quality
75.7
Maintenance
100
Vulnerability
100
License
Developer
reime005
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
12.22.7
NPM Version
6.14.10
Statistics
107 Stars
82 Commits
16 Forks
4 Watching
17 Branches
7 Contributors
Updated on 08 Jul 2024
Bundle Size
7.77 kB
Minified
2.65 kB
Minified + Gzipped
Languages
JavaScript (37.48%)
Java (22.54%)
TypeScript (15.38%)
C++ (10.46%)
Objective-C++ (6.37%)
Objective-C (3.45%)
Ruby (2.35%)
Starlark (0.86%)
Shell (0.69%)
CMake (0.41%)
Total Downloads
Cumulative downloads
Total Downloads
219,687
Last day
-3.5%
139
Compared to previous day
Last week
-9.6%
778
Compared to previous week
Last month
17.6%
3,401
Compared to previous month
Last year
-39.4%
35,313
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
70
Â
Hooks for React Native Camera
Â
React Native Camera Hooks provides you with functionality to use the React Native Camera API with Functional Components.
Â
1import { View, TouchableOpacity, TouchableWithoutFeedback } from 'react-native'; 2import { RNCamera } from 'react-native-camera'; 3import { useCamera } from 'react-native-camera-hooks'; 4 5const FunctionalComponentExample = ({ initialProps }) => { 6 const [ 7 { cameraRef, type, ratio, autoFocus, autoFocusPoint, isRecording }, 8 { 9 toggleFacing, 10 touchToFocus, 11 textRecognized, 12 facesDetected, 13 recordVideo, 14 setIsRecording, 15 }, 16 ] = useCamera(initialProps); 17 18 return ( 19 <View style={{ flex: 1 }}> 20 <RNCamera 21 ref={cameraRef} 22 autoFocusPointOfInterest={autoFocusPoint.normalized} 23 type={type} 24 ratio={ratio} 25 style={{ flex: 1 }} 26 autoFocus={autoFocus} 27 onTextRecognized={textRecognized} 28 onFacesDetected={facesDetected} 29 /> 30 31 <TouchableWithoutFeedback 32 style={{ 33 flex: 1, 34 }} 35 onPress={touchToFocus} 36 /> 37 38 <TouchableOpacity 39 testID="button" 40 onPress={toggleFacing} 41 style={{ width: '100%', height: 45 }}> 42 {type} 43 </TouchableOpacity> 44 45 {!isRecording && ( 46 <TouchableOpacity 47 onPress={async () => { 48 try { 49 setIsRecording(true); 50 const data = await recordVideo(); 51 console.warn(data); 52 } catch (error) { 53 console.warn(error); 54 } finally { 55 setIsRecording(false); 56 } 57 }} 58 style={{ width: '100%', height: 45 }} 59 /> 60 )} 61 </View> 62 ); 63};
Features
- React Hooks Support: Use React Native Camera with Functional Components
- Wrapper around the Camera API, that makes the usage easier
- TypeScript support
Constants are defined in constants and initalState.
Function | Description |
---|---|
useCamera(initialState) | Includes all camera hooks described below. See also the example above |
useZoom(state) | Zoom feature. Includes zoom , setZoom , zoomIn (increment by 0.01) and zoomOut (decrement by 0.1) |
useToggleFacing(state, modes) | Toggles between two values (front and back side of the camera). Includes type , toggleFacing . |
useAutoFocus(state, modes) | Toggles between two values (focus on or off). Includes autoFocus and toggleAutoFocus . |
useWhiteBalance(state) | Toggles between white balance values. Includes whiteBalance , toggleWB and setWhiteBalance . |
useFlash(state) | Toggles between flash modes. Includes flash , toggleFlash and setFlash . |
useAutoFocusTouch(state) | Touch to focus feature. Includes autoFocusPoint , touchToFocus (callback to be used in onPress for example) and setAutoFocusPoint . |
useTextRecognition(state) | Text recognition feature. Includes textBlocks , setTextblocks and textRecognized (callback). |
useFaceDetection(state) | Face detection feature. Includes faces , setFaces and facesDetected (callback). |
useBarcodeDetection(state) | Barcode detection feature. Includes barcodes , setBarcodes and barcodeRecognized (callback). |
takePicture({ cameraRef }, options) | Function to take a picture. Returns a Promise with the result. defaultPictureTakeOptions can also be imported from the same file. |
recordVideo({ cameraRef }, options) | Function to record a video. Returns a Promise with the result. defaultVideoRecordOptions can also be imported from the same file. |
stopRecording({ cameraRef }) | Function to stop recording. Returns a Promise. |
pausePreview({ cameraRef }) | Function to pause the camera preview. Returns a Promise with the result as a boolean. |
resumePreview({ cameraRef }) | Function to resume the camera preview. Returns a Promise with the result as a boolean. |
Â
Installation
To install react-native-camera-hooks, do either
1npm install --save react-native-camera-hooks
or
1yarn add react-native-camera-hooks
Note that this requires a react-native version > 0.59 which supports React Hooks. Also, react-native-camera has to be installed.
Â
TODO
- Improve TypeScript support
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: example/ReactNativeCameraHooks/android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/reime005/react-native-camera-hooks/main.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/reime005/react-native-camera-hooks/main.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v0.5.3 not signed: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/53793411
- Warn: release artifact v0.5.2 not signed: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/50776876
- Warn: release artifact v0.5.1 not signed: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/43163880
- Warn: release artifact v0.5.0 not signed: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/35849429
- Warn: release artifact v0.3.1 not signed: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/21839675
- Warn: release artifact v0.5.3 does not have provenance: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/53793411
- Warn: release artifact v0.5.2 does not have provenance: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/50776876
- Warn: release artifact v0.5.1 does not have provenance: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/43163880
- Warn: release artifact v0.5.0 does not have provenance: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/35849429
- Warn: release artifact v0.3.1 does not have provenance: https://api.github.com/repos/reime005/react-native-camera-hooks/releases/21839675
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 21 are checked with a SAST tool
Reason
76 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-c2jc-4fpr-4vhg
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-q8pj-2vqx-8ggc
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-f5x2-xv93-4p23
- Warn: Project is vulnerable to: GHSA-gmpm-xp43-f7g6
- Warn: Project is vulnerable to: GHSA-pf27-929j-9pmm
- Warn: Project is vulnerable to: GHSA-327c-qx3v-h673
- Warn: Project is vulnerable to: GHSA-x4cf-6jr3-3qvp
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-33f9-j839-rf8h
- Warn: Project is vulnerable to: GHSA-c36v-fmgq-m8hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4r62-v4vq-hr96
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-px4h-xg32-q955
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-7f53-fmmv-mfjv
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-gff7-g5r8-mg8m
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-native-camera-hooks
@react-native-camera-roll/camera-roll
React Native Camera Roll for iOS & Android
react-native-camera
A Camera component for React Native. Also reads barcodes.
react-native-vision-camera
A powerful, high-performance React Native Camera library.
expo-camera
A React component that renders a preview for the device's either front or back camera. Camera's parameters like zoom, auto focus, white balance and flash mode are adjustable. With expo-camera, one can also take photos and record videos that are saved to t