Skip to content

Commit

Permalink
perf: remove useCallback
Browse files Browse the repository at this point in the history
`handleLoad` is directly passed to an HTML tag and therefore render optimization is useless in that case.
  • Loading branch information
dbismut committed Jan 2, 2022
1 parent d3fbae1 commit cd37d28
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Image/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from "react";
import React, { useState } from "react";
import "intersection-observer";
import { useInView } from "react-intersection-observer";

Expand Down Expand Up @@ -114,9 +114,7 @@ export const Image: React.FC<ImagePropTypes> = function ({
}) {
const [loaded, setLoaded] = useState<boolean>(false);

const handleLoad = useCallback(() => {
setLoaded(true);
}, []);
const handleLoad = () => setLoaded(true);

const { ref, inView } = useInView({
threshold: intersectionThreshold || intersectionTreshold || 0,
Expand Down

0 comments on commit cd37d28

Please sign in to comment.