New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error while loading mathjax in react with vite #3222
Comments
There is insufficient information here to determine the cause of your issue. Please fill out the complete issue template rather than deleting it. In particular, the MathJax configuration you are using may be at issue, as well as the method you are using to load MathJax into your application. If this occurs only when a particular expression is in the page, it would help to know that expression as well. Without this information, there is little we can do to help. |
find below information Issue SummaryA summary of the issue and the browser/OS environment in which it occurs. If got the below console error on loading the react component which has the math equations & formula's browser : chrome , OS - window Steps to Reproduce:
tried configuration1 : <script>
MathJax = {
tex: {
inlineMath: [
["$", "$"],
["\\(", "\\)"],
["\ (", "\ )"],
],
},
svg: {
fontCache: "global",
},
};
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script
id="MathJax-script"
async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
></script> tried configuration 2 : added the typesetPromise for the root element <script>
MathJax = {
tex: {
inlineMath: [
["$", "$"],
["\\(", "\\)"],
["\ (", "\ )"],
],
},
svg: {
fontCache: "global",
},
};
MathJax.typesetPromise(document.getElementById('root'))
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script
id="MathJax-script"
async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
></script> Technical details:
I am using the following MathJax configuration: MathJax = {
...
}; and loading MathJax via <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> Supporting information: |
Since you are loading the math content dynamically, you will need to tell MathJax to process the new content when it is in place using I see you are trying to do this, but in your second configuration, you have React maintains its on virtual DOM, so you may run into trouble having MathJax update the DOM outside of React's control. There are a number of MathJax-in-React packages (e.g., better-react-mathjax or mathjax3-react). Perhaps one of these can be used (for example, it looks like As an aside, I'm not sure I understand your |
@dpvc thanks for your suggestion actually it did work as per your suggestion above , i had to move the MathJax.typesetPromis() into the react useeffect where we load the dynamic html instead of the root html of the app closing this issue |
Hi,
We are building a react app with vite and we have some formula's to render in the page using mathjax , when we try to load the component we get below error , need assistance here
The text was updated successfully, but these errors were encountered: