Created
August 26, 2018 22:14
-
-
Save glaucia86/9fdd800a915b5ac3f0e1b64807de8b09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Arquivo: defaultProps-jsx.ts | |
* Author: Glaucia Lemos | |
* Data: 23/08/2018 | |
*/ | |
// Antes: | |
/*export interface Props { name?: string } | |
export class Saudar extends React.Component<Props> { | |
render() { | |
const { nome } = this.props; | |
return <div>Fala ${nome!.toUpperCase()}!</div>; | |
} | |
static defaultProps = { nome: 'Glaucia Lemos' } | |
}*/ | |
// Depois (com a versão 3.0): | |
export interface Props { | |
nome: string | |
} | |
export interface Props { | |
nome: string | |
} | |
export class Saudar extends React.Component<Props> { | |
render() { | |
const { nome } = this.props; | |
return <div>Fala ${nome.toUpperCase()}!</div>; | |
} | |
static defaultProps = { nome: "Glaucia Lemos"} | |
} | |
// Sem a necessidade de fazer uso de tipo assertion aqui: | |
let texto = <Saudar /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment