【问题标题】:react-mathjax renders twice. How can I fix?react-mathjax 渲染两次。我该如何解决?
【发布时间】:2021-02-14 03:24:23
【问题描述】:

我正在尝试在reactjs 中使用react-mathjax

以下是我的代码。

    import React, { useState } from "react";
    import MathJax from "react-mathjax";
    
    export default function App() {
      const [text, setText] = useState("");
      
      const handleOnChange = (e) => {
        setText(e.target.value);
        console.log(e.target.value);
      };
    
      return (
        <>
          <textarea onChange={handleOnChange} />
          <MathJax.Provider>
            <MathJax.Node formula={text} />
          </MathJax.Provider>
        </>
      );
    }

在第一次加载时,它工作正常。但是在输入一些乳胶并擦除后,它会渲染公式两次。

与严格模式无关。我已经试过了。

【问题讨论】:

    标签: reactjs render mathjax


    【解决方案1】:

    有几个名为 react-mathjax 的库。在这种情况下,我假设您正在使用这个:https://github.com/SamyPesse/react-mathjax

    库很久没有更新了。我建议切换到支持 MathJax v3 的维护库。

    选项:

    免责声明:我是 react-mathjax-node 的作者。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-29
    • 2021-09-09
    • 1970-01-01
    • 2022-11-26
    • 2019-05-26
    • 1970-01-01
    • 2020-02-25
    相关资源
    最近更新 更多