fast-reflexes / better-react-mathjax

MIT License
124 stars 16 forks source link

Not working correctly with dangerouslySetInnerHTML #37

Closed ghost closed 1 year ago

ghost commented 1 year ago

Thank you for the great Library.

I am having problems with formulas not being replaced correctly in code using dangerouslySetInnerHTML.

The code is as follows.

<MathJaxContext>
...
  <MathJax>
    <Box dangerouslySetInnerHTML={{ _html=html_from_api_response }}>
    </Box>
  </MathJax>
...
</MathJaxContext>

It works fine when I try it without dangerouslySetInnerHTML.

I would appreciate your help.

fast-reflexes commented 1 year ago

Hi there and thanks!

So, is this data present already when you render the first time or does it come in later? If the data comes in later, you have to set dynamic flag on the MathJax component, otherwise it will not typeset more than once.

ghost commented 1 year ago

I set the MathJax component to dynamic and now it works correctly! Thank you!