rsnext/test/integration/initial-ref/pages/index.js
JJ Kasper 04f1dd52b9 Delay hydration until after page is visible in development (#10164)
* Delay hydration until after page is visible in development

* Tweak dead-code elimination
2020-01-20 21:41:41 +01:00

31 lines
555 B
JavaScript

import React from 'react'
class App extends React.Component {
constructor() {
super()
this.divRef = React.createRef()
this.state = {
refHeight: 0,
}
}
componentDidMount() {
const refHeight = this.divRef.current.clientHeight
this.setState({ refHeight })
}
render() {
const { refHeight } = this.state
return (
<div ref={this.divRef}>
<h1>DOM Ref test using 9.2.0</h1>
<code id="ref-val">{`this component is ${refHeight}px tall`}</code>
</div>
)
}
}
export default App