Skip to content

Obscure DOMChildrenOperations error when doing multiple updates #1147

@sophiebits

Description

@sophiebits

This throws TypeError: Cannot call method 'removeChild' of null.

http://jsbin.com/caxipewo/1/edit

/** @jsx React.DOM */

var X = React.createClass({
  getInitialState: function() {
    return {s: 0};
  },
  render: function() {
    if (this.state.s === 0) {
      return <div>
        <span></span>
      </div>;
    } else if (this.state.s === 1) {
      return <div></div>;
    } else {
      return <span></span>;
    }
  },
  go: function() {
    this.setState({s: 1});
    this.setState({s: 2});
    this.setState({s: 0});
    this.setState({s: 1});
  }
});

var Y = React.createClass({
  render: function() {
    return <div>
      <Z />
    </div>;
  }
});

var Z = React.createClass({
  render: function() { return <div />; },
  componentWillUpdate: function() {
    x.go()
  }
});

var xNode = document.getElementById("x");
var yNode = document.getElementById("y");

var x = React.renderComponent(<X />, xNode);

React.renderComponent(<Y />, yNode);
React.renderComponent(<Y />, yNode);

Maybe this can be simplified some more but this was the simplest repro I could make.

Thanks @fforw for sending a repro case over.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions