Skip to content

Commit

Permalink
add usecallback hook to not createa new function on each render
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Buczacka authored and Walter Buczacka committed Apr 25, 2024
1 parent 268d42e commit 425dbb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next/cms/hooks/useFocus.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {useRef} from "react";
import {useCallback, useRef} from "react";

const useFocus = () => {
const htmlElRef = useRef(null);
const setFocus = () => {
const setFocus = useCallback(() => {
if (htmlElRef.current) htmlElRef.current.focus();
};
}, []);

return [htmlElRef, setFocus];
};
Expand Down

0 comments on commit 425dbb5

Please sign in to comment.