M
M
Maxim Zolotoy2019-02-19 18:28:05
JavaScript
Maxim Zolotoy, 2019-02-19 18:28:05

How to find the root element of a React app?

Is there a way to get the id of the root element of a React app?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-05-01
@spacenear

Weird question, but:

const ROOT_ID = 'root';

ReactDOM.render(<App />, document.getElementById(ROOT_ID));

You can at least export the variable, at least transfer it as a property to App.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question