Skip to content

Commit 001f192

Browse files
committed
feat: 애니메이션 추가
1 parent e384774 commit 001f192

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/pages/editprofile/EditProfile.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState } from 'react';
22
import ProfileEditForm from '@/pages/editprofile/components/ProfileEditForm';
33
import PasswordEditForm from '@/pages/editprofile/components/PasswordEditForm';
44
import { twMerge } from 'tailwind-merge';
5+
import { AnimatePresence, motion } from 'framer-motion';
56

67
function EditProfile() {
78
const [activeTab, setActiveTab] = useState('profile');
@@ -31,13 +32,16 @@ function EditProfile() {
3132
</div>
3233

3334
{/* 폼 */}
34-
{activeTab === 'profile' ? (
35-
// 프로필 수정 탭
36-
<ProfileEditForm />
37-
) : (
38-
// 비밀번호 변경 탭
39-
<PasswordEditForm />
40-
)}
35+
<AnimatePresence mode="wait">
36+
<motion.div
37+
key={activeTab} // 핵심! key를 다르게 주면 된다
38+
initial={{ opacity: 0 }}
39+
animate={{ opacity: 1 }}
40+
transition={{ duration: 0.3 }}
41+
>
42+
{activeTab === 'profile' ? <ProfileEditForm /> : <PasswordEditForm />}
43+
</motion.div>
44+
</AnimatePresence>
4145
</div>
4246
);
4347
}

0 commit comments

Comments
 (0)