Skip to content

Unmount and then wrapper.mount() again does not work properly #941

Open
@innoist

Description

Enzyme: 2.8.2
React: 15.5.4

If we do wrapper.unmount(), and then wrapper.mount(), the component is not mounted properly. I can see an empty console output after mounting again.

Simple plain example as follows

class Foo extends React.Component {
  constructor(props) {
    super(props);
    
  }
  render() {
    return (
      <div className={this.props.id}>
        {this.props.id}
      </div>
    );
  }
}

const wrapper = mount(<Foo id="foo" />);

console.log("log before unmounting", wrapper.mount().debug()); //This logs the component properly

wrapper.unmount();

console.log("Log again after mounting", wrapper.mount().debug());//this logs empty component

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions