Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이미지에 에러나거나 로드 안될 시 기본 이미지 렌더링 #210

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/Search/SearchRestaurantItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from 'react';
import { useRecoilValue, useSetRecoilState } from 'recoil';
import { foodPartyCreateDrawerOpenState } from 'stores/drawer';
import { searchRestaurantListState, selectedRestaurantState } from 'stores/restaurant';
import { DEFAULT_IMAGE } from 'utils/constants/foodParty';
import ROUTING_PATHS from 'utils/constants/routingPaths';
import { getCategoryArray } from 'utils/helpers/foodParty';

Expand Down Expand Up @@ -94,6 +95,8 @@ const SearchRestaurantItem = ({
borderRadius={8}
objectFit='cover'
src={photoUrl}
fallbackStrategy={'onError' || 'beforeLoadOrError'}
fallbackSrc={DEFAULT_IMAGE}
Comment on lines +98 to +99
Copy link
Member

Choose a reason for hiding this comment

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

오호 chakra image props에 이런 게 있었구나 👍

alt='food'
/>
))}
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useSearchRestaurant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { foodPartyCreateDrawerOpenState } from 'stores/drawer';
import { kakaoMapOptionsState } from 'stores/kakaoMap';
import { searchRestaurantListState } from 'stores/restaurant';
import { AxiosPhotoResponseValue } from 'types/kakaoSearch';
import { DEFAULT_IMAGE } from 'utils/constants/foodParty';
import { keywordSearch } from 'utils/helpers/kakaoMap';
import { getKeywordPhotos } from 'utils/helpers/kakaoSearch';

const DEFAULT_IMAGE = '/images/default-restaurant.svg';

const useSearchRestaurant = () => {
const kakaoMapOptions = useRecoilValue(kakaoMapOptionsState);
const setRestaurantList = useSetRecoilState(searchRestaurantListState);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants/foodParty.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const DEFAULT_IMAGE = '/images/default-restaurant.svg';

Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

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

p3;
foodParty.ts에 DEFAULT_IMAGE라고 하면, 밥모임에 대한 기본이미지라고 오해할 수도 있을 거 같아요!
가게에 대한 이미지가 없을 때 보여주는 이미지 맞죠? 조금 더 구체적인 변수명으로 설정하는 건 어떨까요?
ex) DEFAULT_RESTAURANT_IMAGE

export const foodPartyCategory = [
{
title: '신나는 술자리',
Expand Down