mirror of
https://github.com/FranP-code/spooky-spotify-showcase.git
synced 2025-10-13 00:02:36 +00:00
useMemo on ArtistShowcase
This commit is contained in:
@@ -48,7 +48,7 @@ export default function ArtistShowcase({
|
|||||||
const generateSpookyImage = api.entry.generate.useMutation();
|
const generateSpookyImage = api.entry.generate.useMutation();
|
||||||
const saveImage = api.entry.save.useMutation();
|
const saveImage = api.entry.save.useMutation();
|
||||||
|
|
||||||
const error = !!(entry.error || generateSpookyImage.error);
|
const error = useMemo(() => !!(entry.error || generateSpookyImage.error), [entry.error, generateSpookyImage.error]);
|
||||||
|
|
||||||
const handleGenerateSpookyImage = async () => {
|
const handleGenerateSpookyImage = async () => {
|
||||||
if (!entry.data && !entry.isLoading) {
|
if (!entry.data && !entry.isLoading) {
|
||||||
@@ -84,10 +84,12 @@ export default function ArtistShowcase({
|
|||||||
}
|
}
|
||||||
}, [spookyImageLoaded]);
|
}, [spookyImageLoaded]);
|
||||||
|
|
||||||
const spookyImageMatch = (
|
const spookyImageSource = useMemo(() => {
|
||||||
(entry.data?.value || generateSpookyImage.data) as null | string
|
const spookyImageMatch = (
|
||||||
)?.match(/https:\/\/res.cloudinary.com\/[^"]+/);
|
(entry.data?.value || generateSpookyImage.data) as null | string
|
||||||
const spookyImageSource = spookyImageMatch ? spookyImageMatch[0] : null;
|
)?.match(/https:\/\/res.cloudinary.com\/[^"]+/);
|
||||||
|
return spookyImageMatch ? spookyImageMatch[0] : null;
|
||||||
|
}, [entry.data?.value, generateSpookyImage.data]);
|
||||||
|
|
||||||
const onImageLoad = () => {
|
const onImageLoad = () => {
|
||||||
if (!spookyImageLoaded) {
|
if (!spookyImageLoaded) {
|
||||||
@@ -185,3 +187,7 @@ export default function ArtistShowcase({
|
|||||||
</Tilt>
|
</Tilt>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
function useMemo(arg0: () => string | null, arg1: unknown[]) {
|
||||||
|
throw new Error("Function not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user