Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

use-math

mDibyo5MIT0.2.2

Custom React hook to render math inside a DOM node

react, react16, react hooks, react custom hook, math rendering, katex, latex

readme

useMath

React hook for auto-rendering math content in the specified react node.

screenshot

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.