Skip to content

Commit 1724247

Browse files
committed
Fixed issue for fetching user profile
1 parent df731a3 commit 1724247

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/pages/Profile/index.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import { useSelector, shallowEqual } from 'react-redux';
33

44
import { useFormatMessage } from 'hooks';
@@ -8,12 +8,18 @@ import ChangePassword from './ChangePassword';
88

99
const Profile = () => {
1010
const { userData } = useSelector(
11-
state => ({
12-
userData: state.auth.userData
11+
(state) => ({
12+
userData: state.auth.userData,
1313
}),
1414
shallowEqual
1515
);
1616

17+
const [profile, setProfile] = useState(userData);
18+
19+
useEffect(() => {
20+
setProfile(userData);
21+
}, [userData]);
22+
1723
return (
1824
<>
1925
<section className="hero is-hero-bar">
@@ -22,7 +28,13 @@ const Profile = () => {
2228
</div>
2329
</section>
2430
<section className="section is-main-section">
25-
<UserForm isEditing isProfile userData={userData} action={modifyUser} />
31+
<UserForm
32+
isEditing
33+
isProfile
34+
user={profile}
35+
setUser={setProfile}
36+
action={modifyUser}
37+
/>
2638
<ChangePassword />
2739
</section>
2840
</>

0 commit comments

Comments
 (0)