Skip to content
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

Support Render Functions (children being a function) #295

Open
daedalus28 opened this issue Jun 8, 2018 · 5 comments
Open

Support Render Functions (children being a function) #295

daedalus28 opened this issue Jun 8, 2018 · 5 comments

Comments

@daedalus28
Copy link

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.

@pascalduez
Copy link
Contributor

Dupe of #63

@ProdigySim
Copy link

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)

@DavidBabel
Copy link

Any news for this issue ?

This missing feature make the lib kind of useless for newGen React.

@DavidBabel
Copy link

This PR is a first approach to fix the issue : #317

In my case it solve completely my problem.

@march08
Copy link

march08 commented May 15, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants