U
U
Username2018-10-03 12:41:14
JavaScript
Username, 2018-10-03 12:41:14

How to determine whether an element is focused or not using ref?

Good afternoon!
How to use ref to determine whether an element has focus or not? There is a property setting the focus element
this.inputRef.current.focus();
But I still haven't found the property that stores isFocus in itself?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-10-03
@dalv_happy

const isFocused = document.activeElement === this.inputRef.current;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question