Marty
Marty

Reputation: 544

Get height from this.props.children in ReactJS

How to get height from children, passed as props? i mean:

<div>
  {this.props.children} //get height?
</div>

Upvotes: 1

Views: 2437

Answers (1)

Marty
Marty

Reputation: 544

Resolved:

this.childElement.offsetHeight //gives a height

<div ref={(node) => (this.childElement = node)}>{children}</div>

Upvotes: 1

Related Questions