Skip to content

Commit 7cea235

Browse files
committed
docs(react): better click event listener example
1 parent 80fb427 commit 7cea235

File tree

2 files changed

+54
-20
lines changed

2 files changed

+54
-20
lines changed

docs/react/your-first-app/7-live-reload.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,33 @@ const Tab2: React.FC = () => {
143143
Add a click handler to the `<IonImg>` element. When the app user taps on a photo in our gallery, we’ll display an [Action Sheet](../../api/action-sheet.md) dialog with the option to either delete the selected photo or cancel (close) the dialog.
144144

145145
```tsx
146-
<IonGrid>
147-
<IonRow>
148-
{photos.map((photo) => (
149-
<IonCol size="6" key={photo.filepath}>
150-
{/* CHANGE: Add a click event listener to each image */}
151-
<IonImg src={photo.webviewPath} onClick={() => setPhotoToDelete(photo)} />
152-
</IonCol>
153-
))}
154-
</IonRow>
155-
</IonGrid>
146+
<IonPage>
147+
<IonHeader>
148+
<IonToolbar>
149+
<IonTitle>Photo Gallery</IonTitle>
150+
</IonToolbar>
151+
</IonHeader>
152+
<IonContent fullscreen>
153+
<IonHeader collapse="condense">
154+
<IonToolbar>
155+
<IonTitle size="large">Photo Gallery</IonTitle>
156+
</IonToolbar>
157+
</IonHeader>
158+
159+
<IonGrid>
160+
<IonRow>
161+
{photos.map((photo) => (
162+
<IonCol size="6" key={photo.filepath}>
163+
{/* CHANGE: Add a click event listener to each image. */}
164+
<IonImg src={photo.webviewPath} onClick={() => setPhotoToDelete(photo)} />
165+
</IonCol>
166+
))}
167+
</IonRow>
168+
</IonGrid>
169+
170+
{/* Same old code from before. */}
171+
</IonContent>
172+
</IonPage>
156173
```
157174

158175
Remember that removing the photo from the `photos` array triggers the `cachePhotos` method for us automatically.

versioned_docs/version-v7/react/your-first-app/7-live-reload.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,33 @@ const Tab2: React.FC = () => {
143143
Add a click handler to the `<IonImg>` element. When the app user taps on a photo in our gallery, we’ll display an [Action Sheet](../../api/action-sheet.md) dialog with the option to either delete the selected photo or cancel (close) the dialog.
144144

145145
```tsx
146-
<IonGrid>
147-
<IonRow>
148-
{photos.map((photo) => (
149-
<IonCol size="6" key={photo.filepath}>
150-
{/* CHANGE: Add a click event listener to each image */}
151-
<IonImg src={photo.webviewPath} onClick={() => setPhotoToDelete(photo)} />
152-
</IonCol>
153-
))}
154-
</IonRow>
155-
</IonGrid>
146+
<IonPage>
147+
<IonHeader>
148+
<IonToolbar>
149+
<IonTitle>Photo Gallery</IonTitle>
150+
</IonToolbar>
151+
</IonHeader>
152+
<IonContent fullscreen>
153+
<IonHeader collapse="condense">
154+
<IonToolbar>
155+
<IonTitle size="large">Photo Gallery</IonTitle>
156+
</IonToolbar>
157+
</IonHeader>
158+
159+
<IonGrid>
160+
<IonRow>
161+
{photos.map((photo) => (
162+
<IonCol size="6" key={photo.filepath}>
163+
{/* CHANGE: Add a click event listener to each image. */}
164+
<IonImg src={photo.webviewPath} onClick={() => setPhotoToDelete(photo)} />
165+
</IonCol>
166+
))}
167+
</IonRow>
168+
</IonGrid>
169+
170+
{/* Same old code from before. */}
171+
</IonContent>
172+
</IonPage>
156173
```
157174

158175
Remember that removing the photo from the `photos` array triggers the `cachePhotos` method for us automatically.

0 commit comments

Comments
 (0)