Skip to content

Commit

Permalink
implement useFocus custom hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Buczacka authored and Walter Buczacka committed Apr 19, 2024
1 parent d5f1db2 commit 72af363
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/next/cms/hooks/useFocus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {useRef} from "react";

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

return [htmlElRef, setFocus];
};

export {useFocus};

0 comments on commit 72af363

Please sign in to comment.