mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 01:45:17 +00:00
fix: use lazy initializer for useState with function calls
Calling getTerminalKey() and getDefaultDateRange() directly in useState re-runs them on every render. Wrap in an arrow function so they execute only once during component initialization.
This commit is contained in:
@@ -63,7 +63,7 @@ export const ShowRequests = () => {
|
|||||||
const [dateRange, setDateRange] = useState<{
|
const [dateRange, setDateRange] = useState<{
|
||||||
from: Date | undefined;
|
from: Date | undefined;
|
||||||
to: Date | undefined;
|
to: Date | undefined;
|
||||||
}>(getDefaultDateRange());
|
}>(() => getDefaultDateRange());
|
||||||
|
|
||||||
// Check if logs exist to determine if traefik has been reloaded
|
// Check if logs exist to determine if traefik has been reloaded
|
||||||
// Only fetch when active to minimize network calls
|
// Only fetch when active to minimize network calls
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ export const TerminalModal = ({
|
|||||||
serverId,
|
serverId,
|
||||||
asButton = false,
|
asButton = false,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [terminalKey, setTerminalKey] = useState<string>(getTerminalKey());
|
const [terminalKey, setTerminalKey] = useState<string>(() =>
|
||||||
|
getTerminalKey(),
|
||||||
|
);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const isLocalServer = serverId === "local";
|
const isLocalServer = serverId === "local";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user