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

Doesn't work with React.Fragment #34

Closed
RusinovAnton opened this issue Mar 12, 2018 · 5 comments · Fixed by #57
Closed

Doesn't work with React.Fragment #34

RusinovAnton opened this issue Mar 12, 2018 · 5 comments · Fixed by #57
Labels

Comments

@RusinovAnton
Copy link

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>

@ndelangen ndelangen added the bug label Mar 12, 2018
@sharvit
Copy link

sharvit commented 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';

@tuchk4
Copy link
Member

tuchk4 commented Mar 24, 2019

Faced this issue in 5.0.3 with these addons

addDecorator(addReadme);
addDecorator(withInfo);
  • If use together -- Cannot convert a Symbol value to a string
  • If use separately -- no errors.

Maybe relate to this issue storybookjs/storybook#6147

@jasongilmour
Copy link

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

@TomaszWaszczyk
Copy link

As I had the same issue I concluded that either we have React.Fragment without 'withInfo' or 'withInfo' with <div>.

@hipstersmoothie
Copy link
Contributor

As this seems to be a problem in addon-info I suggest someone go fix the bug there. Gonna close this issue since it doesn't have anything to do with addon-jsx

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

Successfully merging a pull request may close this issue.

7 participants