Skip to content

Commit

Permalink
Fix: registered && postPage click close icon
Browse files Browse the repository at this point in the history
  • Loading branch information
cuconveniencestore authored and hookor committed May 31, 2024
1 parent 613e2c4 commit a939c97
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/components/common/HeaderCloseIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useNavigateTo } from '@/hooks/useNavigateTo';
import { iconPropsGenerator } from '@/utils/iconPropsGenerator';
import { useRecoilState } from 'recoil';

//기능 추가필요(useClose수정)
const HeaderCloseIcon = () => {
const goToBack = useNavigateTo('-1');
const [footerState, setFooterState] = useRecoilState(footerShowState);
Expand Down
7 changes: 5 additions & 2 deletions src/components/post/PostRegister.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { useRecoilValue, useResetRecoilState } from 'recoil';
import { useRecoilValue } from 'recoil';
import { nanoid } from 'nanoid';

import CoffeeMenuSelection from '@/components/home/CoffeeMenuSelection';
Expand Down Expand Up @@ -142,7 +142,10 @@ const PostRegister = ({
: await handleUpdate();
await updateTodayCoffeeData();
URL.revokeObjectURL(imageUrl);
registered && navigate(`/post/${postId}`);
registered &&
navigate(`/post/${postId}`, {
state: true
});
};

return (
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useNavigateTo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useNavigate } from 'react-router-dom';

import { useLocation, useNavigate } from 'react-router-dom';
export const useNavigateTo = (to: string) => {
const { pathname, state } = useLocation();
const navigate = useNavigate();
const registered = pathname.includes('post') && state;
const toWhere = () => {
if (registered && to === '-1') {
return navigate('/');
}
if (to === '-1') {
navigate(-1);
return;
Expand Down

0 comments on commit a939c97

Please sign in to comment.