import QRCode from "qrcode";
import React, { useEffect } from "react";
import ErrorMessage from "../ErrorMessage/ErrorMessage";
const QRCodeElement = (props) => {
    const [error, setError] = React.useState(null);
    const [data, setData] = React.useState(null);
    useEffect(() => {
        QRCode.toDataURL(props.text, (err, data) => {
            if (err) {
                setError(err.message);
                return;
            }
            setData(data);
        });
    }, [props.text]);
    if (error) {
        return React.createElement(ErrorMessage, { message: error });
    }
    return (React.createElement("img", { className: "h-42 w-42 flex align-center item-center", src: data || undefined, alt: props.text }));
};
export default QRCodeElement;
//# sourceMappingURL=QR.js.map