import React, {useRef} from "react";

interface IProps {
    url: string,
}

const TextReader: React.FC<IProps> = (props: IProps) => {
    const textAreaRef = useRef<HTMLTextAreaElement>(null);

    fetch(props.url).then((response) => {
        response.text().then((text) => {
            if (textAreaRef.current) {
                textAreaRef.current.value = text;
            }
        });
    });

    return (
        <>
            <textarea className="fm-text-viewer" ref={textAreaRef} rows={10} readOnly={true}></textarea>
        </>
    );
};

export default TextReader;
