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!
Well you can do whatever you want really.
Doing
import { Component } from 'react'
is effectively the same thing asReact.Component
.The
import { Component } from 'react'
syntax is called a Named ImportThis is called named module import.
The module to import from. This is often a relative or absolute path name to the .js file containing the module, excluding the .js extension. Certain bundlers may permit or require the use of the extension; check your environment. Only single quotes and double quotes Strings are allowed.