question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function as children display

See original GitHub issue

Hi,

is react-element-to-jsx-string able to output/format a “Function as children”? (More infos)

const Foo = (props) => (
  <div>
    {props.children()}
  </div>
);

const Bar = () => (
  <Foo>{() => (
    <span>Yeah</span>
  )}</Foo>
);

Output from react-element-to-jsx-string:

<Foo />

Expected output:

<Foo>{() => (
  <span>Yeah</span>
)}</Foo>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pascalduezcommented, Feb 8, 2018

@bnjmn-jns This looks like a different issue your describing, more to do with HOC’s and displayName. Quick fix Text.displayName = 'Text';

More thorough: https://github.com/algolia/react-element-to-jsx-string#reactelementtojsxstringreactelement-options
https://github.com/algolia/react-element-to-jsx-string/blob/master/src/parser/parseReactElement.js#L12-L17

1reaction
vvocommented, Jun 7, 2017

Closing this since for being idle. If you want to work on that @pascalduez, feel free to reopen an issue with more details

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Functions as Children and Render Props in React ...
Children as a function is technically a render prop. However render props allow you to define a complex component and expose dynamic abilities....
Read more >
Function as Child Components Are an Anti-Pattern
A Function as Child Component (or FaCC) is a pattern that lets you you pass a render function to a component as the...
Read more >
CHILDREN Function - Smartsheet Learning Center
Used within another function to reference the child rows of the referenced parent row.
Read more >
React Children And Iteration Methods - Smashing Magazine
Children. toArray , that React gives us, which helps to iterate over the children in a way which ensures performance and determinism. The...
Read more >
Using Children in React - We Learn Code
</Button> and then a button with the text click me would display on the page. For a layout, I could do something like:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found