diff --git a/src/components/place-card/place-card.tsx b/src/components/place-card/place-card.tsx index 5870f8f..246f495 100644 --- a/src/components/place-card/place-card.tsx +++ b/src/components/place-card/place-card.tsx @@ -28,7 +28,7 @@ function PlaceCard({offer, onMouseLeave, onMouseEnter}: PlaceCardProps): JSX.Ele } else { navigate(AppRoute.Login); } - }, [isAuth, isFavorite, offer, dispatch, id]); + }, [isAuth, isFavorite, offer, dispatch, id, navigate]); return (
{ - return prevProps.offer.id === nextProps.offer.id && prevProps.offer.isFavorite === nextProps.offer.isFavorite; -}); +const MemoizedPlaceCard = memo(PlaceCard, (prevProps, nextProps) => prevProps.offer.id === nextProps.offer.id && prevProps.offer.isFavorite === nextProps.offer.isFavorite); export default MemoizedPlaceCard; diff --git a/src/components/review-list/review-list.tsx b/src/components/review-list/review-list.tsx index 42ad00a..8e70d09 100644 --- a/src/components/review-list/review-list.tsx +++ b/src/components/review-list/review-list.tsx @@ -18,7 +18,5 @@ function ReviewList({reviews} : ReviewListProps) : JSX.Element { ); } -const MemoizedReviewList = memo(ReviewList, (prevProps, nextProps) => { - return prevProps.reviews === nextProps.reviews; -}); +const MemoizedReviewList = memo(ReviewList, (prevProps, nextProps) => prevProps.reviews === nextProps.reviews); export default MemoizedReviewList; diff --git a/src/pages/offer-screen/offer-screen.tsx b/src/pages/offer-screen/offer-screen.tsx index 7497166..2fcab2a 100644 --- a/src/pages/offer-screen/offer-screen.tsx +++ b/src/pages/offer-screen/offer-screen.tsx @@ -22,7 +22,7 @@ export function OfferScreen() : JSX.Element { dispatch(fetchDetailOffer(id!)); dispatch(fetchNearOffers(id!)); dispatch(fetchReviews(id!)); - }, [id]); + }, [dispatch, id]); const offer = useAppSelector(getDetailOffer); const nearOffers = useAppSelector(getNearOffers); diff --git a/src/servises/api.ts b/src/servises/api.ts index 68be476..ae718db 100644 --- a/src/servises/api.ts +++ b/src/servises/api.ts @@ -40,7 +40,7 @@ export const createAPI = () : AxiosInstance => { ); } if (error.response && error.response.status === 404) { - store.dispatch(setDetailOffer('NOT_FOUND')); + store.dispatch(setDetailOffer(undefined)); } throw error; }, diff --git a/src/store/detail-offer-data/detail-offer-data.ts b/src/store/detail-offer-data/detail-offer-data.ts index a76e9ae..820f293 100644 --- a/src/store/detail-offer-data/detail-offer-data.ts +++ b/src/store/detail-offer-data/detail-offer-data.ts @@ -15,7 +15,7 @@ export const detailOfferData = createSlice({ name: Namespace.DetailOffer, initialState, reducers:{ - setDetailOffer: (state, action: PayloadAction) => { + setDetailOffer: (state, action: PayloadAction) => { state.detailOffer = action.payload; }, setNearOffers: (state, action: PayloadAction) => { diff --git a/src/store/detail-offer-data/selectors.ts b/src/store/detail-offer-data/selectors.ts index 1f1cd4e..fe2c0e2 100644 --- a/src/store/detail-offer-data/selectors.ts +++ b/src/store/detail-offer-data/selectors.ts @@ -4,6 +4,6 @@ import {Namespace} from '../../const.ts'; import {Offer} from '../../types/offer.ts'; import {Review} from '../../types/review.ts'; -export const getDetailOffer = (state: State): DetailOffer | null => state[Namespace.DetailOffer].detailOffer; +export const getDetailOffer = (state: State): DetailOffer | null | undefined=> state[Namespace.DetailOffer].detailOffer; export const getNearOffers = (state: State): Offer[] => state[Namespace.DetailOffer].nearOffers; export const getReviews = (state: State): Review[] => state[Namespace.DetailOffer].reviews; diff --git a/src/types/state.ts b/src/types/state.ts index a5d1c0c..e3673f0 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -14,7 +14,7 @@ export type AppData = { }; export type DetailOfferData = { - detailOffer: DetailOffer | null | 'NOT_FOUND'; + detailOffer: DetailOffer | null | undefined; nearOffers: Offer[]; reviews: Review[]; };