Skip to content

Conversation

@marlinejohn
Copy link
Collaborator

No description provided.

<Route path="/explore" element={<ExplorePage />} />
<Route path="/card/:id" element={<CardDetailPage />} />
<Route path="/detail" element={<ImageDetailPage />} />
<Route path="/detail/:id" element={<ImageDetailPage />} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ImageDetailPage doesn't seem to handle the id parameter, as in the CardDetailPage component that uses useParams hook to extract the id parameter from the route. My understanding is that if the id is required for rendering the content it might lead to unexpected behavior when the id might be needed for fetching the data or rendering specific details.
My suggestion would be to use the same hook as in the CardDetailsPage to extract the id. If the ImageDetailPage was not intended, might need adjustment.


function ImageDetailPage() {
const location = useLocation();
const { image } = location.state || {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can happen that the location is undefined or the image is missing so we need to check for it.
e.g.
if (!image){ return <div>No image available</div> }

{galleryImages.map((image, index) => (
<div key={index} className={styles.imageContainer}>
<div className={styles.imageWrapper}>
<Link to={`/detail/${index}`} key={index} state={{ image: image }} >
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key prop isn't needed here as you specified it already in line 74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Best of pinterest - link to detail page

4 participants