What does <{}> mean at the end of the extension in javascript?

The following syntax appeared in one of the tutorials for native-native. A component declaration that looks like this:

export default class App extends Component<{}> {

//implementation

}

My question is: what does this mean <{}>and how does this expression differ from this:

export default class App extends Component {

?

+4
source share
3 answers

This snippet is written in typescript. Syntax is <>used to indicate a general restriction on a component.

My advice: if you are not using typescript, you can simply ignore this notation when reading the tutorial. However, if you are interested in learning more:

typescript generics.

Component /-native typescript .

, , (this.props) (this.state).

, {} - , , - . JSX <App />. , {}, , . , ( jsx, typescript).

, , , , <>, - , , "" , this.props. , .

+2

typescript , , <>, - , .

+2

/-, (facebook) flow, typescript,

, , RN-, .js .

In any case, @CRice is true in meaning - it is generic , which in this case indicates the type of props of the class component .

+1
source

Source: https://habr.com/ru/post/1689024/


All Articles