Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoize empty view face so it does not change on rerender #193

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/util/EmptyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
<Box sx={{
position: 'absolute',
Expand All @@ -45,7 +47,7 @@ export default function EmptyView({ message, messageExtra }: IProps) {
}}
>
<Typography variant="h3" gutterBottom>
{getRandomErrorFace()}
{errorFace}
</Typography>
<Typography variant="h5">
{message}
Expand Down