{"size": 967, "ext": "js", "max_stars_repo_path": "web/components/ui/FullWidth.js", "max_stars_repo_name": "messa/ow2", "max_stars_repo_stars_event_min_datetime": "2020-05-11T10:02:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-11T10:02:51.000Z", "max_issues_repo_path": "web/components/ui/FullWidth.js", "max_issues_repo_name": "messa/ow2", "max_issues_repo_issues_event_min_datetime": "2019-04-24T11:44:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-17T20:47:01.000Z", "max_forks_repo_path": "web/components/ui/FullWidth.js", "max_forks_repo_name": "messa/ow2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 17, "max_forks_count": null, "avg_line_length": 17.2678571429, "max_line_length": 57, "alphanum_fraction": 0.5232678387}
import React from 'react'

export default class FullWidth extends React.Component {

  state = {
    height: 40,
  }

  constructor(props) {
    super(props)
    this.contentRef = React.createRef()
  }

  componentDidMount() {
    this.updateHeight()
    this.intervalId = setInterval(this.updateHeight, 500)
  }

  componentWillUnmount() {
    if (this.intervalId) {
      clearInterval(this.intervalId)
    }
  }

  updateHeight = () => {
    const height = this.contentRef.current.offsetHeight
    if (height !== this.state.height) {
      this.setState({ height })
    }
  }

  render() {
    const { children } = this.props
    const { height } = this.state
    return (
      <div
        style={{
          height,
        }}
      >
        <div
          ref={this.contentRef}
          style={{
            position: 'absolute',
            left: 0,
            right: 0,
          }}
        >
          {children}
        </div>
      </div>
    )
  }

}
