Skip to content

ref is undefined in componentDidMount #91

@sourabhdebnath

Description

@sourabhdebnath

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions