Skip to content

Element with prop object containing an element causes maximum call stack error #307

Closed
@samwalshnz

Description

@samwalshnz
import toString from 'react-element-to-jsx-string';

const el = <Element 
	prop={{
		component: <Component />,
	}}
/>

toString(el)

Running the above seems throw the following error:

Uncaught RangeError: Maximum call stack size exceeded
    at Array.sort (:80/native)
    at sortObject (index.js?a730:225)
    at eval (index.js?a730:227)
    at Array.reduce (<anonymous>)
    at sortObject (index.js?a730:225)
    at eval (index.js?a730:227)
    at Array.reduce (<anonymous>)
    at sortObject (index.js?a730:225)
    at eval (index.js?a730:227)
    at Array.reduce (<anonymous>)

Here's a demo: https://stackblitz.com/edit/react-element-to-jsx-string-error?file=index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions