Open bigblind opened 5 years ago
Hit the same problem. Currently working around it with the following:
class EagerMathJaxProvider extends MathJax.Provider {
componentDidMount() {
this.state.registerNode();
super.componentDidMount && super.componentDidMount();
}
}
Thanks for the solution. @StefanSmith
I tried that solution, and because I have a paginated page, and if I paginate fast enough, the math formula occasionally won't render correctly.
For example, I will see the following
Any advice will be appreciated.
My problem is solved by switching to https://github.com/wko27/react-mathjax
MathJax.Provider
callsthis.load()
only incomponentDidMount
andcomponentDidUpdate
.load()
then loads Mathax ifthis.hasNodes
is true, which in turn is set when a node calls theregisterNode
function it receives from the context. ThehasNodes
is stored on the Mathax.Provider instance itself, rather than the state, so setting it doesn't causecomponentDidUpdate
to be called, so at least one component needs to be registered beforecomponentDidMount
is called.So I propose making
hasNodes
part of the state, and will submit a PR to do just that. Let me know if I'm misunderstanding anything.