woodie / common-cartridge-viewer

View Common Cartridges in the browser
https://common-cartridge-viewer.netlify.com
MIT License
1 stars 0 forks source link

LaTeX support with better-react-mathjax #1

Open woodie opened 4 months ago

woodie commented 4 months ago

I'm not sure how to properly configure "better-react-mathjax in this React App.

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
▶ 19 stack frames were collapsed.
CommonCartridge._callee8$
src/CommonCartridge.js:351
  348 |     ? this.state.showcaseResources[0]
  349 |     : null;
  350 | 
> 351 | this.setState({
      | ^  352 |   ...result,
  353 |   externalViewers,
  354 |   isLoaded: true,
  @@ -453,6 +454,8 @@ export default class CommonCartridge extends Component {
     return (
       <I18n>
         {({ i18n }) => (
+          <MathJaxContext>
+          <MathJax>
           <React.Fragment>
             {this.props.compact !== true && (
               <View
@@ -864,6 +867,8 @@ export default class CommonCartridge extends Component {
               </div>
             </div>
           </React.Fragment>
+          </MathJax>
+          </MathJaxContext>
         )}
       </I18n>
     );
fast-reflexes commented 4 months ago

Hi there! better-react-mathjax requires functional components and React 16.8+ and you're using React 16.7 and so it will not work unfortunately :(