Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: 2FA setup and /tools/qr-code-generator crash on v5.2.1

Sturdzza69539d602bfa
diff --git a/web/app/pages/UserSettings/components/TwoFA.tsx b/web/app/pages/UserSettings/components/TwoFA.tsx
index 1631d5654..0d8d2ee34 100644
--- a/web/app/pages/UserSettings/components/TwoFA.tsx
+++ b/web/app/pages/UserSettings/components/TwoFA.tsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
-import QRCode from 'react-qr-code'
+import { QRCode } from 'react-qr-code'
import { useFetcher } from 'react-router'
import { toast } from 'sonner'
import { LockIcon } from '@phosphor-icons/react'
diff --git a/web/app/routes/tools.qr-code-generator.tsx b/web/app/routes/tools.qr-code-generator.tsx
index 2aefea21c..4d7450082 100644
--- a/web/app/routes/tools.qr-code-generator.tsx
+++ b/web/app/routes/tools.qr-code-generator.tsx
@@ -1,6 +1,6 @@
import { DownloadIcon } from '@phosphor-icons/react'
import { useState } from 'react'
-import QRCode from 'react-qr-code'
+import { QRCode } from 'react-qr-code'
import type { MetaFunction } from 'react-router'
import { redirect } from 'react-router'
import type { SitemapFunction } from 'remix-sitemap'
diff --git a/web/app/types.d.ts b/web/app/types.d.ts
new file mode 100644
index 000000000..07ae3b2c2
--- /dev/null
+++ b/web/app/types.d.ts
@@ -0,0 +1,24 @@
+// Module augmentation for `react-qr-code`.
+//
+// The upstream package ships only a default export in its `.d.ts`, but the
+// CJS entry assigns the same component to `exports.QRCode` as well. Vite 8 /
+// Rolldown's `__toESM` helper produces a broken default-interop wrapper for
+// CJS modules whose source already declares `__esModule: true` and its own
+// `default` (the synthetic `.default` ends up pointing at the whole module
+// object instead of the component, so `<QRCode />` renders an object and
+// throws). Importing the existing-but-undeclared `QRCode` named export
+// sidesteps the wrapper.
+declare module 'react-qr-code' {
+ import type { ComponentType, SVGProps, CSSProperties } from 'react'
+
+ export interface QRCodeProps extends SVGProps<SVGSVGElement> {
+ value: string
+ size?: number
+ bgColor?: CSSProperties['backgroundColor']
+ fgColor?: CSSProperties['color']
+ level?: 'L' | 'M' | 'H' | 'Q'
+ title?: string
+ }
+
+ export const QRCode: ComponentType<QRCodeProps>
+}