useMath
React hook for auto-rendering math content in the specified react node.
function MathDiv({ children }) {
const ref = React.createRef();
useMath(ref);
return <div ref={ref}>{children}</div>;
}
ReactDOM.render(
<MathDiv>{"Math here: $$x = \\frac{1}{2}$$"}</MathDiv>,
document.getElementById('root'),
);
Usage
npm install use-math
Then import
import useMath from 'use-math';
Introduction
Under the hood, useMath
uses KaTeX to render the math content.