Skip to content

Commit 360a5da

Browse files
committed
docs(react): use readFile variable
1 parent 524ad6a commit 360a5da

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

docs/react/your-first-app/4-loading-photos.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export function usePhotoGallery() {
8383

8484
// CHANGE: Display the photo by reading into base64 format.
8585
for (const photo of photosInPreferences) {
86-
const file = await Filesystem.readFile({
86+
const readFile = await Filesystem.readFile({
8787
path: photo.filepath,
8888
directory: Directory.Data,
8989
});
90-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
90+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
9191
}
9292

9393
setPhotos(photosInPreferences);
@@ -119,11 +119,11 @@ export function usePhotoGallery() {
119119
const photosInPreferences = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
120120

121121
for (const photo of photosInPreferences) {
122-
const file = await Filesystem.readFile({
122+
const readFile = await Filesystem.readFile({
123123
path: photo.filepath,
124124
directory: Directory.Data,
125125
});
126-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
126+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
127127
}
128128

129129
setPhotos(photosInPreferences);

docs/react/your-first-app/5-adding-mobile.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> =
4848
// CHANGE: Add platform check.
4949
// "hybrid" will detect mobile - iOS or Android
5050
if (isPlatform('hybrid')) {
51-
const file = await Filesystem.readFile({
51+
const readFile = await Filesystem.readFile({
5252
path: photo.path!,
5353
});
54-
base64Data = file.data;
54+
base64Data = readFile.data;
5555
} else {
5656
// Fetch the photo, read as a blob, then convert to base64 format
5757
const response = await fetch(photo.webPath!);
@@ -95,11 +95,11 @@ const loadSaved = async () => {
9595
// If running on the web...
9696
if (!isPlatform('hybrid')) {
9797
for (const photo of photosInPreferences) {
98-
const file = await Filesystem.readFile({
98+
const readFile = await Filesystem.readFile({
9999
path: photo.filepath,
100100
directory: Directory.Data,
101101
});
102-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
102+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
103103
}
104104
}
105105

@@ -132,11 +132,11 @@ export function usePhotoGallery() {
132132
// If running on the web...
133133
if (!isPlatform('hybrid')) {
134134
for (const photo of photosInPreferences) {
135-
const file = await Filesystem.readFile({
135+
const readFile = await Filesystem.readFile({
136136
path: photo.filepath,
137137
directory: Directory.Data,
138138
});
139-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
139+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
140140
}
141141
}
142142

@@ -168,10 +168,10 @@ export function usePhotoGallery() {
168168
let base64Data: string | Blob;
169169
// "hybrid" will detect mobile - iOS or Android
170170
if (isPlatform('hybrid')) {
171-
const file = await Filesystem.readFile({
171+
const readFile = await Filesystem.readFile({
172172
path: photo.path!,
173173
});
174-
base64Data = file.data;
174+
base64Data = readFile.data;
175175
} else {
176176
// Fetch the photo, read as a blob, then convert to base64 format
177177
const response = await fetch(photo.webPath!);

versioned_docs/version-v7/react/your-first-app/4-loading-photos.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export function usePhotoGallery() {
8383

8484
// CHANGE: Display the photo by reading into base64 format.
8585
for (const photo of photosInPreferences) {
86-
const file = await Filesystem.readFile({
86+
const readFile = await Filesystem.readFile({
8787
path: photo.filepath,
8888
directory: Directory.Data,
8989
});
90-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
90+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
9191
}
9292

9393
setPhotos(photosInPreferences);
@@ -119,11 +119,11 @@ export function usePhotoGallery() {
119119
const photosInPreferences = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
120120

121121
for (const photo of photosInPreferences) {
122-
const file = await Filesystem.readFile({
122+
const readFile = await Filesystem.readFile({
123123
path: photo.filepath,
124124
directory: Directory.Data,
125125
});
126-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
126+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
127127
}
128128

129129
setPhotos(photosInPreferences);

versioned_docs/version-v7/react/your-first-app/5-adding-mobile.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ const savePicture = async (photo: Photo, fileName: string): Promise<UserPhoto> =
4848
// CHANGE: Add platform check.
4949
// "hybrid" will detect mobile - iOS or Android
5050
if (isPlatform('hybrid')) {
51-
const file = await Filesystem.readFile({
51+
const readFile = await Filesystem.readFile({
5252
path: photo.path!,
5353
});
54-
base64Data = file.data;
54+
base64Data = readFile.data;
5555
} else {
5656
// Fetch the photo, read as a blob, then convert to base64 format
5757
const response = await fetch(photo.webPath!);
@@ -95,11 +95,11 @@ const loadSaved = async () => {
9595
// If running on the web...
9696
if (!isPlatform('hybrid')) {
9797
for (const photo of photosInPreferences) {
98-
const file = await Filesystem.readFile({
98+
const readFile = await Filesystem.readFile({
9999
path: photo.filepath,
100100
directory: Directory.Data,
101101
});
102-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
102+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
103103
}
104104
}
105105

@@ -132,11 +132,11 @@ export function usePhotoGallery() {
132132
// If running on the web...
133133
if (!isPlatform('hybrid')) {
134134
for (const photo of photosInPreferences) {
135-
const file = await Filesystem.readFile({
135+
const readFile = await Filesystem.readFile({
136136
path: photo.filepath,
137137
directory: Directory.Data,
138138
});
139-
photo.webviewPath = `data:image/jpeg;base64,${file.data}`;
139+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
140140
}
141141
}
142142

@@ -168,10 +168,10 @@ export function usePhotoGallery() {
168168
let base64Data: string | Blob;
169169
// "hybrid" will detect mobile - iOS or Android
170170
if (isPlatform('hybrid')) {
171-
const file = await Filesystem.readFile({
171+
const readFile = await Filesystem.readFile({
172172
path: photo.path!,
173173
});
174-
base64Data = file.data;
174+
base64Data = readFile.data;
175175
} else {
176176
// Fetch the photo, read as a blob, then convert to base64 format
177177
const response = await fetch(photo.webPath!);

0 commit comments

Comments
 (0)