My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

setState in componentDidMount, enzyme tests failing

Manohar Srinivasa's photo
Manohar Srinivasa
·Sep 5, 2018

my cDM looks like the following

cDM() {
  //check if browser supports a feature
 //if yes then setState to denote it is supported
 this.setState( { supports: true });
}

render() {
 if(this.state.supports) // show button;
else // show "not supported" message
}

The "this.setState" call in cDM is making the enzyme "mount" to fail. Any ideas how to fix this? Or is there another way i can achieve it (instead of using state )