algolia / react-element-to-jsx-string

Turn a ReactElement into the corresponding JSX string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

samwalshnz opened this issue · comments

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

Hi there, just to emphaze a bit this issue, it happened to me too & its quite annoying. Would love to see this in the next release, happy to help test this is you need to.

@vvo I hadn't realised how the versioning worked for this repo, and so this PR didn't include an npm version bump. Are we able to retrospectively add one?

@samwalshnz versioning is done at realease time, no need to bump in PRs. Am I missing something else here?