From 65bf9b2419ec65b6c53355986df9a0e2eb593d6f Mon Sep 17 00:00:00 2001 From: molvqingtai Date: Wed, 2 Oct 2024 19:49:54 +0800 Subject: [PATCH] fix: firfox requestAnimationFrame error --- src/app/content/App.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/content/App.tsx b/src/app/content/App.tsx index 9f39ed9..ecc9ead 100644 --- a/src/app/content/App.tsx +++ b/src/app/content/App.tsx @@ -14,6 +14,15 @@ import { Toaster } from 'sonner' import DanmakuContainer from './components/DanmakuContainer' import DanmakuDomain from '@/domain/Danmaku' +/** + * Fix requestAnimationFrame error in jest + * @see https://github.com/facebook/react/issues/16606 + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1469304 + */ +if (import.meta.env.FIREFOX) { + window.requestAnimationFrame = window.requestAnimationFrame.bind(window) +} + export default function App() { const send = useRemeshSend() const roomDomain = useRemeshDomain(RoomDomain()) @@ -46,7 +55,6 @@ export default function App() { danmakuIsEnabled && send(danmakuDomain.command.DestroyCommand()) } }, [danmakuIsEnabled]) - console.log(1) return ( <>