A
A
alex4answ2021-01-11 14:44:38
React
alex4answ, 2021-01-11 14:44:38

How to allow a component to be mounted only as a child of another?

Good afternoon, how can I make sure that my component is mounted deeper in the tree than the specified one?

So far I've only met a hack - use the context and check it.
Are there other ways how this is usually implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2021-01-11
@alex4answ

The context method is the only possible one. And it's not a hack, it's quite a normal option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question