How can I respond to the width of an auto-sized DOM element in React?

前端 未结 4 1958

I have a complex web page using React components, and am trying to convert the page from a static layout to a more responsive, resizable layout. However, I keep running into

4条回答
  •  轮回少年
    2020-12-22 18:08

    Alternatively to couchand solution you can use findDOMNode

    var Container = React.createComponent({
    
      componentDidMount: function () {
        var width = React.findDOMNode(this).offsetWidth;
      },
    
      render: function () {
        
      }
    });
    

提交回复
热议问题