next.js/test/integration/initial-ref/pages/index.js
index.js32 lines598 B
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} style={{ height: 76, overflow: 'hidden' }}>
        <h1>DOM Ref test using 9.2.0</h1>
        <code id="ref-val">{`this component is ${refHeight}px tall`}</code>
      </div>
    )
  }
}

export default App
Quest for Codev2.0.0
/
SIGN IN