Files
bigcapital/client/src/hooks/useAutofocus.js
a.bouhuolia f8ee455985 feat: make journal auto-adjustment for entries.
feat: auto-focus cells inside the table.
2021-01-27 15:02:12 +02:00

14 lines
244 B
JavaScript

import { useRef, useEffect } from 'react';
export default function useAutofocus(focus = true) {
const ref = useRef();
useEffect(() => {
if (ref.current && focus) {
ref.current.focus();
}
}, [ref, focus]);
return ref;
}