Any difference between React.Component and Component?

前端 未结 3 1480
名媛妹妹
名媛妹妹 2021-01-21 22:18

I have seen two ways of accessing Component:

import React from \'react\';

class Foo extends React.Component {
    ...
}

and

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 22:48

    No, it's just a matter of what you import into the local namespace. If you already have something called Component locally, you wouldn't be able to do the latter. Other than that it's just preference, whether you want to list everything that's imported up top, or instead be able to easily see which module something is from at usage sites.

提交回复
热议问题