Skip to content

Commit

Permalink
frontend test fix: useMemo hook inside another hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhav91one committed Nov 18, 2024
1 parent 58ed355 commit 4cd8d46
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions frontend/taipy-gui/src/components/Taipy/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ const GetStatusIcon = (status: string, withIcons?: boolean): ReactNode => {
const color = status2Color(status);

// Memoize the iconProps
const iconProps = useMemo(() => ({
sx: { fontSize: 20, color: `${color}.main` },
}), [color]); // Recalculate iconProps when `color` changes

return useMemo(() => {
const iconProps = {
sx: { fontSize: 20, color: `${color}.main` }}

if (withIcons) {
switch (color) {
case "success":
Expand All @@ -75,7 +73,7 @@ const GetStatusIcon = (status: string, withIcons?: boolean): ReactNode => {
} else {
return getInitials(status);
}
}, [status, withIcons, color, iconProps]); // Memoize based on `status`, `withIcons`, `color`, and `iconProps`

};


Expand Down

0 comments on commit 4cd8d46

Please sign in to comment.