Skip to content

Commit ea6f86c

Browse files
docs(native): properly type camera example usage (#3175)
Updating to prevent error message "Type 'string | undefined' is not assignable to type 'string'. --------- Co-authored-by: Brandy Carney <brandyscarney@gmail.com>
1 parent 068e1f5 commit ea6f86c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/native-setup.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import { Camera, CameraResultType } from '@capacitor/camera';
7575
7676
@Component({...})
7777
export class CameraComponent{
78-
public imageSrc = '';
78+
public imageSrc: string | undefined = '';
7979
8080
async takePicture() {
8181
const image = await Camera.getPhoto({
@@ -86,7 +86,6 @@ export class CameraComponent{
8686
const imageUrl = image.webPath;
8787
this.imageSrc = imageUrl;
8888
};
89-
9089
}
9190
```
9291
@@ -102,7 +101,7 @@ export class CameraComponent{
102101
<script setup lang="typescript">
103102
import { ref } from 'vue';
104103
import { Camera, CameraResultType } from '@capacitor/camera';
105-
const imageSrc = ref('');
104+
const imageSrc = ref<string | undefined>('');
106105
107106
const takePicture = async () => {
108107
const image = await Camera.getPhoto({
@@ -126,7 +125,7 @@ import { Camera, CameraResultType } from '@capacitor/camera';
126125
import { useState } from 'react';
127126
128127
export function CameraComponent() {
129-
const [imageSrc, setImageSrc] = useState('');
128+
const [imageSrc, setImageSrc] = useState<string | undefined>('');
130129
131130
const takePicture = async () => {
132131
const image = await Camera.getPhoto({

0 commit comments

Comments
 (0)