Skip to content

String is not an array, but the library thinks it is. #886

@andret2344

Description

@andret2344

Initial checklist

Affected package

react-markdown@9.0.3

Steps to reproduce

In a typescript project, do this:

const description: string = '# 123';
<Markdown>{description}</Markdown>
// or
<Markdown children={description} />

Actual behavior

Assertion
Unexpected value 123 for children prop, expected string

Image

Expected behavior

A string should be treated as a string.

Initial investination

The problem appears in this code:

Image

By default, the children prop is an array, and that's a designed by React behavior. Instead of throwing an error, it can be parsed, i.e., using the .join() method in case of an array. It's impossible to pass a string as the children prop in such a way that React won't convert it to an array.

Runtime

Chrome 133.0.6943.54 (Official Build) (64-bit), node@22.13.0

Package manager

yarn@1.22.19, npm@11.1.0

Operating system

Microsoft Windows 11 24H2 (Build 26100.3037)

Build and bundle tools

webpack

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