fast-reflexes / better-react-mathjax

MIT License
132 stars 16 forks source link

Fix: reset equation numbers to avoid `Label multiply defined` error. #30

Closed guanghechen closed 2 years ago

guanghechen commented 2 years ago

Hi @fast-reflexes , thank you for creating such a awesome project, I'm really appreciate it! But I encountered a typesetting bug when using this package, so I create this pr and hope this pr can fix it.

Scenario

In a single-page application, when we switch routes and trigger the MathJax to re-render the page, if a formula in the page uses the \label instruction, it will cause the Label multiple 'xxx' defined error.

Changes

guanghechen commented 2 years ago

Close this pr as it fix nothing.

fast-reflexes commented 2 years ago

Thanks for contributing! I'm sorry the fix didn't work ... is there an alternate fix? Could you supply a code sandbox showing the problem and I can see how it can be fixed? Thanks for trying :)

guanghechen commented 2 years ago

Hi @fast-reflexes , thanks for the reply!

I have tried many ways to fix this problem but got nothing. The issue is that when switching routes, components will be unmounted and then re-mounted, but equation numbers are not cleared. I created a demo to show the problem, see https://codesandbox.io/s/vigorous-bird-h7fsuw?file=/src/App.js, hope it helps :)