enzymejs/enzyme

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

Open

#941 geöffnet am 13. Mai 2017

Auf GitHub ansehen
 (6 Kommentare) (3 Reaktionen) (0 zugewiesene Personen)JavaScript (2.016 Forks)batch import
API: mountbughelp wantedquestion

Repository-Metriken

Stars
 (19.979 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide