Components
The React Native SDK exports two native UI components.
DetectionCameraView
A native camera preview surface used in scanning flows (barcode scanning, live detection).
Import
import { DetectionCameraView } from '@passiolife/nutritionai-react-native-sdk-v3'Props
Extends standard ViewProps (accepts style, testID, etc.).
Usage
<DetectionCameraView style={{ flex: 1 }} />Place it in your component tree wherever you need a camera preview. The SDK manages the underlying AVCaptureSession (iOS) and CameraX (Android) lifecycle automatically.
With Barcode Scanning
import { useEffect } from 'react'
import {
PassioSDK,
DetectionCameraView,
} from '@passiolife/nutritionai-react-native-sdk-v3'
function BarcodeScanner() {
useEffect(() => {
const subscription = PassioSDK.startBarcodeScanning((event) => {
const barcodes = event.barcodeCandidates ?? []
barcodes.forEach(({ barcode }) => {
console.log('Scanned barcode:', barcode)
})
})
return () => subscription.remove()
}, [])
return <DetectionCameraView style={{ flex: 1 }} />
}PassioIconView
Renders food icon images associated with Passio item IDs. The component fetches and caches icons from the Passio icon service.
Import
Props
Prop
Type
Description
config.passioID
PassioID
The Passio ID to display an icon for
config.iconSize
IconSize
Icon resolution: PX90, PX180, or PX360
Also accepts standard ViewProps.
Usage
Circular Icon Example
Last updated