From 1510c5a093f8a2017db51875a3a5a3c063875562 Mon Sep 17 00:00:00 2001 From: Valter Martinek Date: Thu, 10 Nov 2022 19:01:29 +0100 Subject: [PATCH] Memoize empty view face so it does not change on rerender (#193) --- src/components/util/EmptyView.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/util/EmptyView.tsx b/src/components/util/EmptyView.tsx index f41246ba..17730098 100644 --- a/src/components/util/EmptyView.tsx +++ b/src/components/util/EmptyView.tsx @@ -6,7 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // adopted from: https://github.com/tachiyomiorg/tachiyomi/blob/master/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt -import React from 'react'; +import React, { useMemo } from 'react'; import Typography from '@mui/material/Typography'; import { useTheme } from '@mui/material/styles'; import { useMediaQuery } from '@mui/material'; @@ -35,6 +35,8 @@ export default function EmptyView({ message, messageExtra }: IProps) { const theme = useTheme(); const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm')); + const errorFace = useMemo(() => getRandomErrorFace(), []); + return ( - {getRandomErrorFace()} + {errorFace} {message}