E
E
eugenedrvnk2020-12-05 12:59:21
React
eugenedrvnk, 2020-12-05 12:59:21

What is the best way to export components?

When writing components on my own, I usually use names in the spirit of:

<Menu>
  <MenuItem/>
  <MenuItem/>
</Menu>


Now we have to work with the AntDesign library and they have the same menu done as follows:

<Menu>
  <Menu.Item/>
  <Menu.Item/>
</Menu>


This approach is used simply to indicate that a MenuItem cannot be used outside of a menu, i.e. is not a standalone component? Or is there some other reason why they might choose this approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex K, 2020-12-05
@alexk111

This approach is recommended in the official react guide as a convenient way to refer to components when a single module exports many components.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question