Mathpix / mathpix-markdown-it

Markdown rendering + Latex extras (equations, tables, ...), with conversion features, for the scientific community
MIT License
501 stars 44 forks source link

Update react versions to latest and fix typing #285

Closed ethancatzel closed 7 months ago

ethancatzel commented 11 months ago

I am implementing MathpixMarkdown and MathpixLoader in a NextJS 13 environment and I have the following error:

'MathpixLoader' cannot be used as a JSX component.
  Its type 'typeof MathpixLoader' is not a valid JSX element type.
    Type 'typeof MathpixLoader' is not assignable to type 'new (props: any, deprecatedLegacyContext?: any) => Component<any, any, any>'.
      Construct signature return types 'MathpixLoader' and 'Component<any, any, any>' are incompatible.
        The types of 'refs' are incompatible between these types.
          Type '{ [key: string]: import("/Users/ethan/code/opensource/mathpix-markdown-it/node_modules/@types/react/index").ReactInstance; }' is not assignable to type '{ [key: string]: React.ReactInstance; }'.
            'string' index signatures are incompatible.
              Type 'import("/Users/ethan/code/opensource/mathpix-markdown-it/node_modules/@types/react/index").ReactInstance' is not assignable to type 'React.ReactInstance'.
                Type 'Component<any, {}, any>' is not assignable to type 'ReactInstance'.
                  Type 'import("/Users/ethan/code/opensource/mathpix-markdown-it/node_modules/@types/react/index").Component<any, {}, any>' is not assignable to type 'React.Component<any, {}, any>'.
                    The types returned by 'render()' are incompatible between these types.
                      Type 'import("/Users/ethan/code/opensource/mathpix-markdown-it/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'.
                        Type '{}' is not assignable to type 'ReactNode'.ts(2786)

To fix this, I have updated the react related packages. I have run yarn test and everything passed, and I have linked this fix with my local project and it worked.

ethancatzel commented 11 months ago

cc @OlgaRedozubova

JakovGlavac commented 9 months ago

Having the same issue

jackobV commented 7 months ago

Having the same issue with next js 13 cc @OlgaRedozubova

GolliAch commented 7 months ago

Same issue!

OlgaRedozubova commented 7 months ago

@GolliAch @jackobV @JakovGlavac @ethancatzel Fixed in mathpix-markdown-it@1.3.0

Example in codesandbox

Screenshot 2024-02-17 at 10 14 44