ReactJS get rendered component height

前端 未结 9 1634
夕颜
夕颜 2020-12-29 02:29

I\'m attempting to integrate or create a React version of https://github.com/kumailht/gridforms, to do so I need to normalize the height of the columns inside of the row. Th

9条回答
  •  执念已碎
    2020-12-29 03:26

    According this answer sizes of a component can be turned out having zero width or height inside componentDidMount event handler. So I'm seeing some ways to solve it.

    1. Handle the event on top-level React component, and either recalculate the sizes there, or redraw the specific child component.

    2. Set the load event handler on the componentDidMount to handle loading the cells into the react component to recalculate the proper sizes:

      componentDidMount = () => {
         this.$carousel = $(this.carousel)
         window.addEventListener('load', this.componentLoaded)
      }
      

      Then in the componentLoaded method just do what you need to do.

提交回复
热议问题