I just got in a project on React Native, where I constantly see classes extending both React.Component
and Component
itself.
Examples:
class SomeView extends React.Component
or
class OtherView extends Component
in both of them we are importing React, {Component} from React
Is there any actual difference, if so, which one? Didn't found any info on the web. Cheers!
import { Component } from 'react'
, you are importingReact.Component
. Meaning that if you, at the beginning of the file, writeimport React, { Component } from 'react'
,React.Component
refers to the exact same class asComponent
, making both syntaxes you mentioned valid.