William Luis Alberton
William Luis Alberton

Reputation: 21

ReactJS - Get height of dynamic div with no css height defined

I'm having some problem to get height of a dynamic created div. This div does not have css height property defined. I'm using React JS. I tried use jQuery, pure javascript and React tools to get DOM Node, but the result is always 0. If i try $(....).height() at console, the value is showed correctly. Anyone can help me? Thanks.

Upvotes: 1

Views: 2690

Answers (2)

William Luis Alberton
William Luis Alberton

Reputation: 21

I realized that the problems is with react life cycles. I created a new question about it. ReactJS - ComponentDidMount is executing before render

Upvotes: 0

Jörn
Jörn

Reputation: 845

I've created a tiny fiddle to reproduce your issue and it's reading the height properly. Notice, that i'm using reacts ref attribute and ReactDOM.findDOMNode() to access the <div>.

https://jsfiddle.net/03ejh9yk/3/

https://facebook.github.io/react/docs/more-about-refs.html
https://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode

Upvotes: 1

Related Questions