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

React children errors thrown for nested components #986

Closed
danielduan opened this issue May 1, 2017 · 3 comments
Closed

React children errors thrown for nested components #986

danielduan opened this issue May 1, 2017 · 3 comments
Labels

Comments

@danielduan
Copy link
Member

danielduan commented May 1, 2017

On the latest master, something is breaking the react children and how the render loops are working. This is from an old existing project that I'm trying to migrate over. It uses the info and knob addons.

Invariant Violation: Objects are not valid as a React child (found: object with keys {content}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons.
    at invariant (http://localhost:9001/static/preview.bundle.js:759:15)
    at traverseAllChildrenImpl (http://localhost:9001/static/preview.bundle.js:21588:23)
    at traverseAllChildren (http://localhost:9001/static/preview.bundle.js:21616:10)
    at Object.instantiateChildren (http://localhost:9001/static/preview.bundle.js:39918:7)
    at ReactDOMComponent._reconcilerInstantiateChildren (http://localhost:9001/static/preview.bundle.js:44724:41)
    at ReactDOMComponent.mountChildren (http://localhost:9001/static/preview.bundle.js:44763:27)
    at ReactDOMComponent._createInitialChildren (http://localhost:9001/static/preview.bundle.js:41763:32)
    at ReactDOMComponent.mountComponent (http://localhost:9001/static/preview.bundle.js:41582:12)
    at Object.mountComponent (http://localhost:9001/static/preview.bundle.js:9572:35)
    at ReactCompositeComponentWrapper.performInitialMount (http://localhost:9001/static/preview.bundle.js:40414:34)
trimResultTransformer.js:21 Uncaught TypeError: Cannot read property 'emit' of null
    at trimResultTransformer.js:21

I'm rendering the components inside a wrapper component that provides a css background and environment layout.

const React = require('react');
const { PropTypes } = React;

const stylesheet = require('./ComponentWrapper.css');

const ComponentWrapper = React.createClass({
  propTypes: {
    theme: PropTypes.string
  },

  getDefaultProps() {
    return {
      theme: 'default'
    };
  },

  render() {
    return (
      <div className={ stylesheet[this.props.theme] }>
        <div className={ stylesheet.container }>
          { this.props.children }
        </div>
      </div>
    );
  }
});

module.exports = ComponentWrapper;

If I delete the line { this.props.children}, the wrapper renders fine. Is there something that's messing with how child components passed through?

@danielduan danielduan changed the title React children React children errors thrown when switching between stories May 1, 2017
@danielduan danielduan changed the title React children errors thrown when switching between stories React children errors thrown for nested components May 1, 2017
@shilman shilman added the bug label May 12, 2017
@tmeasday
Copy link
Member

tmeasday commented Jun 1, 2017

Are you still seeing this? I think a bunch of users are running into it.

If you are can you post the following:

  • npm version
  • output of npm list

We think the issue comes about if the package has its own copy of addons.

@danielduan
Copy link
Member Author

danielduan commented Jun 1, 2017

I don't see this anymore, I ended up flushing my node_modules. I think it's an issue of having the right react and react-dom versions installed since it is a peer dependency.

I wonder if changing the addon-info's react-dom dependency to a peer dependency would fix it since you could have something like [email protected] running with [email protected] causing problems.

@tmeasday
Copy link
Member

tmeasday commented Jun 1, 2017

Hmm, it's just the Cannot read property 'emit' of null which we've seen come from multiple copies of @storybook/addons.

In any case it sounds like flusing node_modules solved it, we probably can't do anything else with this bug now.

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

No branches or pull requests

3 participants