react-element-to-jsx-string
react-element-to-jsx-string copied to clipboard
Support Render Functions (`children` being a function)
Right now, react-element-to-jsx-string seems to ignore function children. With the new context API using a function for children, this is extra important.
Dupe of #63
There's a number of different patterns for overloading children
outlined in this article: https://medium.com/@martin_hotell/react-children-composition-patterns-with-typescript-56dfc8923c64
I'm using the 2nd one (named slot projection), and this also kills react-element-to-jsx-string:
Uncaught Error: react-element-to-jsx-string: Expected a React.Element, got `object`
at parseReactElement (parseReactElement.js:51)
Any news for this issue ?
This missing feature make the lib kind of useless for newGen React.
This PR is a first approach to fix the issue : https://github.com/algolia/react-element-to-jsx-string/pull/317
In my case it solve completely my problem.
Cannot really confirm that it solved for me. Otherwise really great lib, worked the best so far.
My code:
<Dropdown>
{({ handleClose }) => (
<>
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={handleClose}>Item 2 with close</DropdownItem>
</>
)}
</Dropdown>
Result
<Dropdown />
Options
showDefaultProps: false,
showFunctions: true,
maxInlineAttributesLineLength: 100,
Cheers guys