Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extends Component<Props> vs extends React.Component

Tags:

react-native

What's the difference between

type Props = {};
export default class App extends Component<Props>

And

export default class App extends React.Component

Both ways of extending seem to work without any errors.

like image 957
Kamuffel Avatar asked Jul 18 '18 20:07

Kamuffel


1 Answers

<Props> part is just Flow feature for type checking. It will be ignored if you haven't integrated Flow. Component and React.Component is the same class from react package, a difference only in importing:

import React from 'react';
export default class App extends React.Component

import React, { Component } from 'react';
export default class App extends Component
like image 65
Oleksandr Blyzniuk Avatar answered Oct 18 '22 09:10

Oleksandr Blyzniuk