How to Access styles from React?

前端 未结 5 1636
时光取名叫无心
时光取名叫无心 2020-12-24 14:10

I am trying to access the width and height styles of a div in React but I have been running into one problem. This is what I got so far:

componentDidMount()         


        
5条回答
  •  执念已碎
    2020-12-24 14:29

    You already get the style, the reason why CSSStyleDeclaration object's props have so much empty string value is it's link to the inner style.

    See what will happen if you make change like below:

提交回复
热议问题