The MathJax component provides a way to both load MathJax on the page and render MathJax Nodes. Many people love ❤️ beautifully typeset mathematics, and these components are the way to provide it.
```jsx
const { Provider, Node } = require("@nteract/mathjax");
const tex = String.raw`f(x) = \int_{-\infty}^\infty
\hat f(\xi)\,e^{2 \pi i \xi x}
\,d\xi`;
This is an inline math formula: a = b and a block one:{tex}
;
```
The components are written in a React 16+ way to both load mathjax through a `` and render individual MathJax nodes with ``. React does the heavy lifting of knowing what changed and the `` component triggers having MathJax do what it's good at — _typesetting mathematics_!
This semi-contrived example shows
```jsx
const { Provider, Node } = require("@nteract/mathjax");
const verbs = ["do", "can", "should", "will"];
class CleanUpdates extends React.Component {
constructor(props) {
super(props);
this.state = {
exponent: 1,
verb: "can"
};
}
componentDidMount() {
this.intervals = [
setInterval(() => {
this.setState(state => ({
exponent: (state.exponent + 1) % 10
}));
}, 3001), // Prime
setInterval(() => {
this.setState(state => ({
verb: verbs[Math.floor(Math.random() * verbs.length)]
}));
}, 557) // Also prime
];
}
componentWillUnmount() {
this.intervals.map(id => clearInterval(id));
}
render() {
return (
We{" "}
{this.state.verb}
{" "}
update
{"n^" + this.state.exponent} pieces of a paragraph
without triggering a MathJax re-render.
);
}
}
;
```
If you use `` with no provider, a `` is created for you automatically.
```jsx
const { Node } = require("@nteract/mathjax");
a = b;
```