From cd37d28366fc68c16b2b3c4bd72cc43cefc6836d Mon Sep 17 00:00:00 2001 From: David Bismut Date: Sun, 2 Jan 2022 13:12:18 +0100 Subject: [PATCH] perf: remove useCallback `handleLoad` is directly passed to an HTML tag and therefore render optimization is useless in that case. --- src/Image/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Image/index.tsx b/src/Image/index.tsx index 3607f01..5e195af 100644 --- a/src/Image/index.tsx +++ b/src/Image/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from "react"; +import React, { useState } from "react"; import "intersection-observer"; import { useInView } from "react-intersection-observer"; @@ -114,9 +114,7 @@ export const Image: React.FC = function ({ }) { const [loaded, setLoaded] = useState(false); - const handleLoad = useCallback(() => { - setLoaded(true); - }, []); + const handleLoad = () => setLoaded(true); const { ref, inView } = useInView({ threshold: intersectionThreshold || intersectionTreshold || 0,