I got error of TypeError: Cannot read property 'offsetHeight' of undefined when trying to get offsetHeight of a dom node.
componentDidMount() {
setTimeout(function(){
console.log(this.contentBody.offsetHeight)
},1000)
}
I suspect this is caused my async where the ref is not yet set. My render method look like this
<div ref={elem => this.contentBody = elem} className="content-body" dangerouslySetInnerHTML={createMarkupFromReferenceContent()} />
I tried to create a non ajax demo here https://codesandbox.io/s/j46o2656vy and it worked. That's why I try the setTimeout hack above, but no luck. Any clue how to solve this?