How to display Math equations in React Native View

后端 未结 2 1064
自闭症患者
自闭症患者 2021-02-18 21:49

How to render Math equations in React Native Views? For web applications, we can use LaTex or MathJax solutions. But React Native renders native components. Using WebView will b

相关标签:
2条回答
  • 2021-02-18 22:29

    MathJax let you use render SVG so you may try to generate SVG and then render it inside of React Native ( I am pretty sure that it won't work out of the box, but at least it is a way )

    0 讨论(0)
  • 2021-02-18 22:39

    There is a library for MathJax in React Native. Library does not work properly sometimes, but you should try it. https://github.com/calvinkei/react-native-mathjax#readme

    Usage

    <MathJax
      // HTML content with MathJax support
      html={'$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$<br><p>This is an equation</p>'}
      // MathJax config option
      mathJaxOptions={{
        messageStyle: 'none',
        extensions: [ 'tex2jax.js' ],
        jax: [ 'input/TeX', 'output/HTML-CSS' ],
        tex2jax: {
          inlineMath: [ ['$','$'], ['\\(','\\)'] ],
          displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
          processEscapes: true,
        },
        TeX: {
          extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js']
        }
      }}
      {...WebView props}
    />
    
    0 讨论(0)
提交回复
热议问题