fast-reflexes / better-react-mathjax

MIT License
132 stars 16 forks source link

MathJax works correctly in Local build but not in Server deploy #56

Closed EricBatlle closed 9 months ago

EricBatlle commented 9 months ago

Hi again! I'm trying to deploy my website that uses this better-react-mathjax library. I deploy with Vercel, and deploy is succesful, webiste is looking great locally, but with the hosted version, the one served by Vercel, it appears to not use MathJax at all.

So I've no error, neither on deploy neither in console, it's simply not rendering :(

Is it normal? What am I missing?

Thanks for the help!

EricBatlle commented 9 months ago

Okey seems like adding the "dynamic" tag to the Mathjax component fixed it but...I don't know why, I'll like to understand the reason ^^'

fast-reflexes commented 9 months ago

Hi there!

When you run locally with a dev server, for hot reload to work properly, all MathJax elements are implicitly dynamic if not explicitly set to dynamic={false}. You probably always use the MathJax elements in a dynamic way (e.g. you rely on typesetting being done after the component is initially mounted) and so it works without the dynamic flag when you run it locally but not in a production environment. The remedy is, as you have discovered, to add the dynamic flag :)

This could be better documented which I will consider :) Feel free to close if you have received the info you were looking for :)