提问人:watchI 提问时间:10/6/2023 最后编辑:watchI 更新时间:10/7/2023 访问量:28
React 组件不更新 mathjax 公式,除非其名称以小写开头
React component not updating mathjax formula unless its name starts with a lower case
问:
我的 React (^18.2.0) 项目包含几个组件。所有这些组件都包含 mathjax (better-react-mathjax) 公式和文本。当我更新文本时,它会在浏览器中正确更新。当我更新 mathjax 公式时,除非与组件相关的函数名称以小写开头,否则我在浏览器中看不到任何更新。
例如,这个组件 () 更新了公式,但是当我将名称从 更改为 时,公式不会更新:SetTheory1.js
R_{XY}
setThor1
SetThor1
import { MathJax, MathJaxContext } from "better-react-mathjax";
const setThor1 = () => {
return (
<div className="ddd">
<MathJaxContext>
<MathJax inline>
this is a formula \({"R_{XY}"} \)
</MathJax>
</MathJaxContext>
</div>
);
};
export default setThor1;
在这两种情况下,文本 () 都会正确更新。为什么!?我希望公开组件的 const 的命名只是一种约定,对更新渲染组件没有影响。"this is a formula"
/App.js************/
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
//import { MathJax, MathJaxContext } from "better-react-mathjax";
import Header from "./templateComponents/Header";
import Side from "./templateComponents/Side";
import Footer from "./templateComponents/Footer";
import IntroToProbaAndStat from "./Components/Introduction to proba and stat";
import SetThe2 from "./Components/setTheory2";
import SetTheo1 from "./Components/SetTheory1";
import RandomExp from "./Components/randomExperiment";
import RandomVar1 from "./Components/randomVariable1";
import RandomVar2 from "./Components/randomVariable2";
import RandomVar3 from "./Components/randomVariable3";
import RandomVar4 from "./Components/randomVariable4";
import ExampleUseEffectC from "./Components/UseEffectExample";
import "./assets/css/StatStyle.css";
function Appk() {
return (
<Router>
<div className="App">
<Header />
<Side />
<Footer />
<div
id="sec"
style={{ backgroundColor: "rgb(245,244,240)" }}
className="absolute p-4 max-sm:w-[30%] right-0 text-lg top-9 h-[90%] w-[70%] overflow-y-auto"
>
<Switch>
<Route exact path="/IntrToProbaP">
<IntroToProbaAndStat />
</Route>
<Route exact path="/setThe1P">
<SetTheo1 />
</Route>
<Route exact path="/setThe2P">
<SetThe2 />
</Route>
<Route exact path="/randomExpP">
<RandomExp />
</Route>
<Route exact path="/randomVarP1">
<RandomVar1 />
</Route>
<Route exact path="/randomVarP2">
<RandomVar2 />
</Route>
<Route exact path="/randomVarP3">
<RandomVar3 />
</Route>
<Route exact path="/randomVarP4">
<RandomVar4 />
</Route>
<Route exact path="/ExampleUseEffect">
<ExampleUseEffectC />
</Route>
</Switch>
</div>
</div>
</Router>
);
}
export default Appk;
答: 暂无答案
评论
export default function SetThor1() { ... }