<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mulugeta Chernet</title>
    <description>The latest articles on DEV Community by Mulugeta Chernet (@mullerx).</description>
    <link>https://dev.to/mullerx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1252644%2F6fc63001-2091-42a7-8cad-f9906721e45f.jpeg</url>
      <title>DEV Community: Mulugeta Chernet</title>
      <link>https://dev.to/mullerx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mullerx"/>
    <language>en</language>
    <item>
      <title>🐱‍👤Leveraging MathJax in React.js with CDN✨</title>
      <dc:creator>Mulugeta Chernet</dc:creator>
      <pubDate>Tue, 09 Jan 2024 18:58:02 +0000</pubDate>
      <link>https://dev.to/mullerx/leveraging-mathjax-in-reactjs-with-cdn-1jeo</link>
      <guid>https://dev.to/mullerx/leveraging-mathjax-in-reactjs-with-cdn-1jeo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4WwcRM6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb8qqjb6y22uv8lmo9gc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4WwcRM6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb8qqjb6y22uv8lmo9gc.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;MathJax is a JavaScript display engine for mathematics that works in all browsers. Integrating MathJax into a React.js application can be a game-changer for projects that involve mathematical expressions, equations, or any kind of mathematical notation. MathJax, a powerful JavaScript library, makes it easy to display mathematical content beautifully on the web. In this blog post, we'll explore how to seamlessly incorporate MathJax into your React.js application using a CDN (Content Delivery Network).&lt;/p&gt;

&lt;h2&gt;
  
  
  step 1: Install MathJax using CDN
&lt;/h2&gt;

&lt;p&gt;In your &lt;em&gt;public/index.html&lt;/em&gt; file, add the MathJax CDN link in the &lt;em&gt;head&lt;/em&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;script type="text/javascript" async
      src="https://polyfill.io/v3/polyfill.min.js?features=es6"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script id="MathJax-script" async
      src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"&amp;gt;
    &amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  step 2: Create a Component for MathJax Rendering
&lt;/h2&gt;

&lt;p&gt;In your &lt;em&gt;src/components/MathJaxComponent.js:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useEffect } from 'react';

const MathJaxComponent = ({ mathExpression }) =&amp;gt; {
  useEffect(() =&amp;gt; {
    window.MathJax.typeset();
  }, [mathExpression]);

  return (
    &amp;lt;div&amp;gt;
      {mathExpression &amp;amp;&amp;amp; (
        &amp;lt;span
          dangerouslySetInnerHTML={{ __html: mathExpression }}
        /&amp;gt;
      )}
    &amp;lt;/div&amp;gt;
  );
};

export default MathJaxComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Use the MathJax Component in Your App
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  const mathExpression = '\\[x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.\\]'; // Replace with your mathematical expression

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;MathJax in React.js&amp;lt;/h1&amp;gt;
      &amp;lt;MathJaxComponent mathExpression={mathExpression} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4BwrAHbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfzbub3uu9s6y0ts8mmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4BwrAHbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfzbub3uu9s6y0ts8mmt.png" alt="Image description" width="285" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;By following these steps, you can seamlessly integrate MathJax into your React.js application using a CDN. Whether you're building an educational platform, a scientific tool, or any other project involving mathematical content, MathJax will elevate the quality and accessibility of your mathematical expressions on the web. Happy coding!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
