N
N
Ninja Mate2016-04-04 13:46:17
JavaScript
Ninja Mate, 2016-04-04 13:46:17

What's the easiest way to get the width of an element in React without jQuery?

There was a need to make the D3 library graphics adaptive, but the width={920} ​​attribute does not work with percentages. Hence the question, how to get the width of a div element in react?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2016-04-04
@victorzadorozhnyy

document.getElementById("mydiv").offsetWidth;
React actually has nothing to do with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question