N
N
Nikolai Antonov2016-08-05 18:05:45
React
Nikolai Antonov, 2016-08-05 18:05:45

How to get the width in px of an element via this.refs.elem?

I set on the element ref="table". Then I get it via refs:

// after render
    componentDidMount() {
        let el = this.refs['table'];
        el.getBoundingClientRect(); // не работает
    }

I tried how to get the selector ( link ) in the documentation, from the docks -
var input = this.refs.myInput;
var inputRect = input.getBoundingClientRect();

What is the problem? Is there another way to get the width of an element?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question