-
-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String is not an array, but the library thinks it is. #886
Comments
Hi! The simplest answer to your very weird problem of strings suddenly being numbers or arrays is: you are making a mistake. Try and make a small reproduction (
No, it is not that, by default. Try and reproduce with babel. If |
This comment has been minimized.
This comment has been minimized.
Hi, yeah, I crafted the code, my bad. Here's a real example: const description: string = '# abc';
console.log(description, typeof description);
<Markdown>{description}</Markdown>
// also doesn't work
<Markdown children={description} /> Tried also: <Markdown># abc</Markdown>
// and
<Markdown children='# abc' /> In every case, the result is as follows: If I'm making a mistake, I'd love to know what it is, but for now there's no way to render anything except for an empty body. |
Yes, you are making a mistake, but it’s not an obvious one. Something in your toolchain is wrapping that string into single item array. Likely suspects are a bad JSX compiler or a bad custom JSX runtime implementation. Have a look at how |
Initial checklist
Affected package
[email protected]
Steps to reproduce
In a typescript project, do this:
Actual behavior
Assertion
Unexpected value
123
forchildren
prop, expectedstring
Expected behavior
A string should be treated as a string.
Initial investination
The problem appears in this code:
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 thechildren
prop in such a way that React won't convert it to an array.Runtime
Chrome 133.0.6943.54 (Official Build) (64-bit), [email protected]
Package manager
[email protected], [email protected]
Operating system
Microsoft Windows 11 24H2 (Build 26100.3037)
Build and bundle tools
webpack
The text was updated successfully, but these errors were encountered: