CameraErrorEvent
The camera failed or can't run: ERR_PERMISSION (access denied),
ERR_CAMERA_UNAVAILABLE (no such camera, or none on this device), or
ERR_CAMERA (the session failed or was interrupted).
Utilização
Capture a photo and preview the result
import { Button, Camera, Image, VStack, cameraRef, signal } from 'kuito';
export default function Snap() {
const camera = cameraRef();
const photo = signal<string | null>(null);
async function take() {
try {
const picture = await camera.current?.takePicture({ quality: 0.8 });
photo.value = picture?.uri ?? null;
} catch (error) {
console.log('No picture:', error);
}
}
return (
<VStack flex={1}>
<Camera
ref={camera}
flex={1}
facing="back"
onError={(event) => console.log(event.code, event.message)}
/>
<Button disabled={!camera.ready.value} onPress={() => void take()}>
Take picture
</Button>
{photo.value ? <Image src={photo.value} width={96} height={96} /> : null}
</VStack>
);
}Declaração do tipo
export type CameraErrorEvent = NativeViewEvent<'error', { code: string; message: string }>;Membros 5
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | "error" | Sim | — |
target | unknown | Sim | — |
isTrusted | boolean | Sim | — |
code | string | Sim | — |
message | string | Sim | — |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.