Any difference between React.Component and Component?

前端 未结 3 1472
名媛妹妹
名媛妹妹 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:53

    In first example you got the whole exports through import React, and you call Component through react import. In second example you import Component separately from React. That's why you don't need to write React.Component. It's the same, but in different ways of import.

提交回复
热议问题