How does react register components globally like vue?

use antd components first import {xxx} from "antd"

is there any way to register components globally at the entrance so that you don"t have to import every time

Mar.06,2021

No.
antd is referenced on demand and componentized, assuming that all components can be injected at once. Do you think it's reasonable?
must not be reasonable, is it?


this. It should not be possible.


I haven't heard of it, but if the page doesn't need it, there's no need to quote it. It's better to quote it on demand.


for those who answer, I suggest you learn vue, and so on, you will know what its on-demand import means when you learn vue. React really has no way to import on demand in one place, without the need to import each time. There is also no way for the global component of react to achieve global injection, which does not need to be imported from every page. It can only be said that this is the limitation of react, or that vue has done a lot of work for us to make our code more concise. In the simplest case, react has to import every component once react, which is very redundant. I don't want to complain, but I just want to say that react developers and designers can't think about things from the user's point of view.

Menu