react-mathjax icon indicating copy to clipboard operation
react-mathjax copied to clipboard

Flash of unstyled math every render

Open tscizzle opened this issue 6 years ago • 3 comments

When a Mathjax element is first rendered, it has an awkward-looking flash where you can see the math but it's not styled.

When rendering some static math content to a page, it seems there is a solution (outlined here: https://github.com/mathjax/MathJax/issues/131). I think it's saying you can hide the Mathjax element until Mathjax has loaded / run or whatever, and then only unhide it when things re ready, so that you don't get the awkward-looking flash of unstyled math.

But with React, if your math content contains any dynamic value, then you don't just render the Mathjax element once. You render it every time the value changes. This means the above-described solution doesn't work, and you get the awkward-looking flash many many times (depending on how often the data changes, but that could be a ton if a user is modifying relevant things.)

Wondering if there is an analogous solution for react-mathjax, or if anyone else has had this issue and has a good way to handle it.

tscizzle avatar Aug 01 '18 04:08 tscizzle

I have the same problem, do you have a solution to handle it?

chuxusave avatar Nov 14 '18 08:11 chuxusave

Using this react-mathjax fork might solve this problem: https://github.com/wko27/react-mathjax (registered as react-mathjax2 in npm).

nikolas avatar Feb 21 '19 20:02 nikolas

@nikolas How did that package solve your problem?

LuisOsta avatar Jan 09 '21 23:01 LuisOsta