Replies: 1 comment 2 replies
-
IMHO this is not supposed to happen, we expect the ref to be set before the mutation observer fires
We could but the goal is not to swallow problems and burry. If we add that check, then nobody will ever report us problems we might have, like you did here. Apart from an annoying Sentry warning, does it cause any harm? If not, then you can safely ignore the Sentry warning and just report us a possible bug. Since the ref being set is an expectation we have, instead of using if (!codeBlockRef.current) {
throw new Error("unexpected, the ref isn't set while it should be");
} It wouldn't solve the Sentry error though, and would just provide a clearer error. It's quite difficult to analyze this bug, but the very first step would probably be to check all your swizzled components. Did you swizzle anything in |
Beta Was this translation helpful? Give feedback.
-
Got this error from Sentry, because in hook
useCodeWordWrap
you don't check if the ref is not null. The code even uses!
to disable the check in TypeScript.https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts#L80-L82
The hook is used in
theme/CodeBlock/Content/CodeBlockString
that I swizzled, but the ref is included in the DOM. I only changed the style attribute of the code when specific language is included.Any clue why the error is happening? From my understanding, this should throw every time, but it doesn't throw when I tested my website.
Is there a possibility of adding a null check to that hook?
The error happen on Android and mobile Chrome. I was not able to reproduce it.
Beta Was this translation helpful? Give feedback.
All reactions