ref is undefined in componentDidMount
sourabhdebnath opened this issue · comments
The ref
is undefined
in componentDidMount
. We have a condition where we need to show the modal when the components first render. Here is the code snippet
componentDidMount() {
this.skylightModal.show();
}
...
render(){
...
<SkyLight
hideOnOverlayClicked ref={ref => this.skylightModal = ref}
>...
...
}
However, in componentDidMount
, it throws the following error -
Uncaught TypeError: Cannot read property 'show' of undefined
Not sure if I am doing something wrong. Kindly help here.