Rendering Math in React Component

Ionware

I am trying to Render Math Equation in a React Component with MathJax. It actually worked well if I pre-render it within the HTML file, but it is a mess when i try rendering it in React.

Here's my code

class Latex extends React.Component {

constructor(props) {
    super(props);
}

componentDidMount(){
    MathJax.Hub.Queue(['Typeset', MathJax.Hub, ReactDOM.findDOMNode(this)]);
}

componentDidUpdate() {
    MathJax.Hub.Queue(['Typeset', MathJax.Hub, ReactDOM.findDOMNode(this)]);
}

render() {
    //dangerouslySetInnerHTML={{__html: this.props.children}}
    return (
         <h5 dangerouslySetInnerHTML={{__html: this.props.children}}></h5>
    );
}
}

Math Display both in Regular HTML and React Element

Ionware

Oh no, I was so disappointed in myself when I found out what I was doing wrong. I applied display of Block to the Span element that renders the Latex (My take was that it would treat the whole chunk as one) and it put each Equation character onto a separate line. Changing the display to "inline" fixed the problem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Simple React component not rendering

From Java

Dynamically Rendering a React component

From Dev

React router not rendering component

From Dev

React router not rendering component

From Dev

Rendering a Component Instance in React

From Dev

React not rendering component

From Dev

Basic react component not rendering

From Dev

Controlling Order of React Component Rendering

From Dev

React - server side component rendering

From Dev

React - server side component rendering

From Dev

Component rendering with React in Rails not working

From Dev

Method in React component not rendering HTML

From Dev

Rendering react component in html page

From Dev

React Router component rendering twice

From Dev

Rendering a dynamic child component in React

From Dev

React: Rendering the component in different way

From Dev

React component not rendering on route changed

From Dev

React component not rendering on with latest version

From Dev

React Parent Component Not Rendering Child Component

From Dev

Dynamically Rendering a React Component in React 0.12

From Dev

React router dynamic routes not rendering component

From Dev

React component not re-rendering on state change

From Dev

Selectively rendering optional component properties in React JSX

From Dev

find size of react component or image before rendering

From Dev

How to test decorated React component with shallow rendering

From Dev

Rendering a React component inside a Bootstrap popover

From Dev

Redux + React-router component not rendering

From Dev

Error in Rendering UI using React Component

From Dev

Isomorphic React and JSX - rendering component as string on server

Related Related

HotTag

Archive