Check that you are not accessing ref before the child component has been mounted. E.g. it doesn’t work in componentWillMount
. A different pattern which auto invokes ref related callback after the element has been mounted is this-
<div ref={(elem)=>(console.log(elem))}/>
You can use this notation to get mounted elements in deep nesting as well –
<div ref={this.props.onMounted}/>