Skip to content

Commit 903e89c

Browse files
committed
simply comments
1 parent fb0682d commit 903e89c

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

src/components/StyledQrCode.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import QRCodeStyling, { Options } from 'qr-code-styling';
22
import React, { useEffect, useMemo, useRef, useState } from 'react';
33

4-
// Make all properties optional and add React-specific props
54
type StyledQRCodeProps = Partial<Options> & {
65
className?: string;
76
download?: boolean;
87
};
98

10-
// Helper function to convert Blob or Buffer to object URL
119
const blobToUrl = (blob: Blob | Buffer, mimeType: string): string => {
1210
if (blob instanceof Blob) {
1311
return URL.createObjectURL(blob);
1412
}
1513

16-
// Convert Buffer to Blob - Buffer is a Uint8Array, so we can use it directly
1714
const uint8Array = new Uint8Array(blob);
1815
const blobObj = new Blob([uint8Array], { type: mimeType });
1916
return URL.createObjectURL(blobObj);
@@ -62,7 +59,6 @@ const StyledQRCode: React.FC<StyledQRCodeProps> = ({
6259
? (prevRestKeyRef.current = currentRestKey)
6360
: prevRestKeyRef.current;
6461

65-
// Memoize the mime type
6662
const mimeType = useMemo(
6763
() => (type === 'svg' ? 'image/svg+xml' : 'image/png'),
6864
[type],
@@ -89,7 +85,6 @@ const StyledQRCode: React.FC<StyledQRCodeProps> = ({
8985
qrCode.current.update(options);
9086
}
9187

92-
// Get the data URL and set it as the image source
9388
let cancelled = false;
9489
qrCode.current.getRawData(type === 'svg' ? 'svg' : 'png').then((blob) => {
9590
if (blob && !cancelled) {
@@ -109,8 +104,6 @@ const StyledQRCode: React.FC<StyledQRCodeProps> = ({
109104
imageSrcRef.current = '';
110105
}
111106
};
112-
// Note: qrOptions, imageOptions, dotsOptions, backgroundOptions are intentionally
113-
// not in deps to avoid loops. They're included in options object which is used.
114107
// eslint-disable-next-line react-hooks/exhaustive-deps
115108
}, [type, shape, width, height, margin, data, restKey, mimeType]);
116109

0 commit comments

Comments
 (0)