useAutosizeTextArea

Creating a Textarea with dynamic height.

Usage

import React, { useState } from "react";
import useAutosizeTextArea from 'funda-ui/Utils/useAutosizeTextArea';
 
 
const App = () => {
    const [value, setValue] = useState("");
    const el = useRef<HTMLTextAreaElement>(null);
 
    useAutosizeTextArea({
        el: el.current, 
        value: value,
        cb: (res) => {
            console.log('dimensions: ', res);
        }
    });
 
    const handleChange = (evt: React.ChangeEvent<HTMLTextAreaElement>) => {
        const val = evt.target?.value;
        setValue(val);
    };
 
    return (
        <div className="App">
            <textarea
                onChange={handleChange}
                ref={el}
                rows={3}
                value={value}
            />
        </div>
    );
};