Fix ProfilePage effect dependency
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
|
||||||
import { Alert, Avatar, Box, Button, Chip, Divider, FormControl, InputLabel, LinearProgress, MenuItem, Paper, Select, TextField, Typography } from "@mui/material";
|
import { Alert, Avatar, Box, Button, Chip, Divider, FormControl, InputLabel, LinearProgress, MenuItem, Paper, Select, TextField, Typography } from "@mui/material";
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ export default function ProfilePage() {
|
|||||||
const [currentPassword, setCurrentPassword] = useState("");
|
const [currentPassword, setCurrentPassword] = useState("");
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
|
|
||||||
async function loadProfile() {
|
const loadProfile = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const r = await api.get<MeResponse>("/auth/me");
|
const r = await api.get<MeResponse>("/auth/me");
|
||||||
setMe(r.data);
|
setMe(r.data);
|
||||||
@@ -135,11 +135,11 @@ export default function ProfilePage() {
|
|||||||
} catch {
|
} catch {
|
||||||
setMe(null);
|
setMe(null);
|
||||||
}
|
}
|
||||||
}
|
}, [t]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadProfile();
|
void loadProfile();
|
||||||
}, []);
|
}, [loadProfile]);
|
||||||
|
|
||||||
const initials = useMemo(() => initialsFrom([me?.displayName, me?.firstName, me?.lastName, me?.userName, me?.email]), [me]);
|
const initials = useMemo(() => initialsFrom([me?.displayName, me?.firstName, me?.lastName, me?.userName, me?.email]), [me]);
|
||||||
const isLocal = me?.provider === "local";
|
const isLocal = me?.provider === "local";
|
||||||
|
|||||||
Reference in New Issue
Block a user