Skip to content

Cannot run the code after upgrading the library: missing property code.inline and changed the type of p.ref #776

@MartinXPN

Description

@MartinXPN

Initial checklist

Affected packages and versions

"react-markdown": "^9.0.0",

Link to runnable example

No response

Steps to reproduce

I have the following component that used to work fine:

                    <ReactMarkdown components={{
                        p: ({node, ...props}) => <Typography whiteSpace="pre-wrap" {...props} />,
                        code: ({node, inline, className, children, ...props}) => {
                            const match = /language-(\w+)/.exec(className || '')
                            return !inline && match
                                ? <LazyCode content={String(children)} language={match[1]} />
                                : <code className={className} {...props}>{children}</code>
                        },
                    }}>{conversation.raw?.trim()}
                    </ReactMarkdown>

Now, I get the following errors:

  1.  p.ref -->        Type 'string' is not assignable to type '((instance: HTMLSpanElement | null) => void) | RefObject | null | undefined'.
  2. code.inline --> TS2339: Property 'inline' does not exist on type 'ClassAttributes & HTMLAttributes & ExtraProps'.

I'm using node@18.17.0 with next@13.5.4

Expected behavior

It used to work fine using the previous version

Actual behavior

The code does not compile

Runtime

Other (please specify in steps to reproduce)

Package manager

yarn 2

OS

Linux, macOS

Build and bundle tools

Next.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions