mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed errors on Textareas without setRef
This commit is contained in:
parent
b90b44de2c
commit
7d2511e7e9
4 changed files with 25 additions and 14 deletions
|
@ -49,7 +49,7 @@ const Textarea = memo<IProps>(
|
|||
}) => {
|
||||
const [rows, setRows] = useState(minRows || 1);
|
||||
const [focused, setFocused] = useState(false);
|
||||
const ref = useRef<HTMLTextAreaElement>();
|
||||
const ref = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
const onInput = useCallback(
|
||||
({ target }: ChangeEvent<HTMLTextAreaElement>) => handler(target.value),
|
||||
|
@ -64,7 +64,10 @@ const Textarea = memo<IProps>(
|
|||
if (!target) return;
|
||||
|
||||
autosize(target);
|
||||
setRef(target);
|
||||
|
||||
if (setRef) {
|
||||
setRef(target);
|
||||
}
|
||||
|
||||
return () => autosize.destroy(target);
|
||||
}, [ref, setRef]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue