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

Error when calling this.setState in componentDidMount when using reagent's mount #27

Closed
iancmyers opened this issue Nov 17, 2015 · 3 comments
Assignees

Comments

@iancmyers
Copy link
Contributor

I have a component that looks like this:

class MySharona extends React.Component {
  constructor(props) {
    super(props);
    this.state = {mounted: false};
  }

  componentDidMount() {
    this.setState({mounted: true});
  }

  render() {
    return <div>{this.state.mounted}</div>;
  }
}

I've got a test that looks like this:

import { expect } from 'chai';
import { mount, describeWithDom } from 'reagent';
import React from 'react';

import MySharona from './MySharona.js';

describeWithDom('MySharona', () => {
  it('passes my test', () => {
    const wrapper = mount(<MySharona />);
    expect(wrapper.find('div').text).to.be('true');
  });
});

Instead of getting a passing test, I get a horrible, horrible error, that crushes my soul and makes me sad:

Error: Invariant Violation: dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make surewindowanddocumentare available globally before requiring React when unit testing or use React.renderToString for server rendering.

@lelandrichardson
Copy link
Collaborator

I definitely want to preserve the structural integrity of your soul, Ian. I'll get working on this. Thanks for the bug report!

@lelandrichardson
Copy link
Collaborator

I've been able to reproduce this, and confirmed that this only happens with react 0.13. 0.14 works fine.

@lelandrichardson
Copy link
Collaborator

Fix is merged.

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

No branches or pull requests

2 participants