Skip to content

Commit

Permalink
feat: 이미지 전체화면에서 뒤로가기 시 모달만 닫기
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 3, 2023
1 parent 636d534 commit 520b312
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
16 changes: 15 additions & 1 deletion src/components/ImageFullScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { Carousel } from 'react-responsive-carousel';
import 'react-responsive-carousel/lib/styles/carousel.min.css';
import { useNavigate } from 'react-router-dom';

import DeleteIcon from '@/components/icons/DeleteIcon';

Expand All @@ -17,6 +18,19 @@ export default function ImageFullScreen({
}: ImageFullScreenProps) {
const [index, setIndex] = useState(initialIndex);

useEffect(() => {
const handlePopState = () => {
history.go(1);
onClose();
};

window.addEventListener('popstate', handlePopState);
return () => {
handlePopState();
window.removeEventListener('popstate', handlePopState);
};
}, []);

return (
<div className="fixed left-0 top-0 z-[100] h-[100dvh] w-screen bg-text-title-900">
<div className="absolute top-[1rem] z-[100] flex w-full items-center justify-between px-[1.3rem]">
Expand Down
20 changes: 10 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<Provider>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>
{/*<ReactQueryDevtools initialIsOpen={false} />*/}
</QueryClientProvider>
</React.StrictMode>
// <React.StrictMode>
<QueryClientProvider client={queryClient}>
<Provider>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>
{/*<ReactQueryDevtools initialIsOpen={false} />*/}
</QueryClientProvider>
// </React.StrictMode>
);

// If you want your app to work offline and load faster, you can change
Expand Down

0 comments on commit 520b312

Please sign in to comment.