setState in componentDidMount, enzyme tests failing
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 )
Start a personal dev blog on your domain for free and grow your readership.
3.4K+ developers have started their personal blogs on Hashnode in the last one month.
Write in Markdown 路 Publish articles on custom domain 路 Gain readership on day zero 路 Automatic GitHub backup and more
look at this stackoverflow.com/questions/38003578/reactj.. maybe this doesn't refer to your component class
Comments (1)