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.

Doesn't work with React.Fragment

See original GitHub issue

Hello

I’ve tried to use addon-jsx for story that uses React.Fragment like this:

 .addWithJSX('bubble with components inside of it', () => (
    <Fragment>
      <MyComponent props />
      <MyComponent otherProps/>
    </Fragment>
  ));

and it fails with error:

Cannot convert a Symbol value to a string
    at exports.default (http://localhost:9001/static/preview.bundle.js:85619:17)
    at exports.default (http://localhost:9001/static/preview.bundle.js:81301:49)
    at exports.default (http://localhost:9001/static/preview.bundle.js:85518:39)
    at reactElementToJsxString (http://localhost:9001/static/preview.bundle.js:85494:35)
    at http://localhost:9001/static/preview.bundle.js:85400:50
    at mapSingleChildIntoContext (http://localhost:9001/static/preview.bundle.js:15121:26)
    at traverseAllChildrenImpl (http://localhost:9001/static/preview.bundle.js:14994:5)
    at traverseAllChildren (http://localhost:9001/static/preview.bundle.js:15065:10)
    at mapIntoWithKeyPrefixInternal (http://localhost:9001/static/preview.bundle.js:15141:3)
    at Object.mapChildren [as map] (http://localhost:9001/static/preview.bundle.js:15163:3)

It works perfectly once I replace <Fragment> with plain <div>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
sharvitcommented, Mar 29, 2018

I am facing the same issue with https://github.com/storybooks/storybook/tree/master/addons/info This temporary solution/hack works for me:

React.Fragment = ({ children }) => children;
React.Fragment.propTypes = {
  children: PropTypes.node.isRequired
};
React.Fragment.displayName = 'React.Fragment';
4reactions
jasongilmourcommented, Apr 16, 2019

I also see this issue with the combination of React.Fragment and the withInfo addon in Storybook 5.0.6

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Fragment not rendering in function [duplicate]
My api query works fine and I can get the data I'm after but I'm struggling displaying it in the component. import React...
Read more >
Fragments - React
A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding...
Read more >
Can't use React.Fragment · Issue #12097 - GitHub
Use <React.Fragment></React.Fragment> or <></> syntax to render mapped fragments. ... Try to render the component. Get met with this error:.
Read more >
Understanding React fragments - LogRocket Blog
Fragments are syntax that allow us to add multiple elements to a React component without wrapping them in an extra DOM node. ......
Read more >
React Fragments: Eliminate Unnecessary Divs - G2i
React Fragments are used here to group together the other nodes, making it a single element being returned by MyComponent and it doesn't...
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