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";
|
||||
|
||||
@@ -106,7 +106,7 @@ export default function ProfilePage() {
|
||||
const [currentPassword, setCurrentPassword] = useState("");
|
||||
const [newPassword, setNewPassword] = useState("");
|
||||
|
||||
async function loadProfile() {
|
||||
const loadProfile = useCallback(async () => {
|
||||
try {
|
||||
const r = await api.get<MeResponse>("/auth/me");
|
||||
setMe(r.data);
|
||||
@@ -135,11 +135,11 @@ export default function ProfilePage() {
|
||||
} catch {
|
||||
setMe(null);
|
||||
}
|
||||
}
|
||||
}, [t]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadProfile();
|
||||
}, []);
|
||||
}, [loadProfile]);
|
||||
|
||||
const initials = useMemo(() => initialsFrom([me?.displayName, me?.firstName, me?.lastName, me?.userName, me?.email]), [me]);
|
||||
const isLocal = me?.provider === "local";
|
||||
|
||||
Reference in New Issue
Block a user