1 year ago
#67308

jozinho22
Why do my Component lost while rendering the next page?
I'm using MathJax for the first time and I did success to display some simple formule like 'a x b = c' in a quizz whith several questions.
On the first page, my formula displayed well but not the others, as you can see on the inspector the component disappear...
Here is the first question :
And the second question :
Here is the code where I am mounting the component :
function createRandomQuestions() {
var nbQuestions = 10;
var maxInt = 15;
var randomQuestions = [];
for (var i = 0; i < nbQuestions; i++) {
var randomInt1 = getRandomInt(maxInt);
var randomInt2 = getRandomInt(maxInt);
var enounceModel = "\\({" + randomInt1 + "}\\times{"+ randomInt2 + "} = \\)";
console.log(enounceModel)
var question = {
enounce: <MathJaxDisplay
enounceModel={enounceModel}/>
,
answer: randomInt1*randomInt2
}
randomQuestions.push(question);
}
CustomLogger("randomQuestions", randomQuestions, 'TableTestHome')
setQuestions(randomQuestions);
return randomQuestions;
}
And
MathJaxDisplay
is just a custom Component englobing the regex :
"\\({a}\\times{b} = \\)"
;
import React from 'react';
import { MathJax, MathJaxContext } from "better-react-mathjax";
const MathJaxDisplay = ({enounceModel}) => {
return (
<MathJaxContext>
<MathJax>
{enounceModel}
</MathJax>
</MathJaxContext>
);
}
export default MathJaxDisplay;
Thank you for your help
reactjs
string
formula
display
mathjax
0 Answers
Your Answer