Skip to content

Instantly share code, notes, and snippets.

@glaucia86
Created August 26, 2018 22:14
Show Gist options
  • Save glaucia86/9fdd800a915b5ac3f0e1b64807de8b09 to your computer and use it in GitHub Desktop.
Save glaucia86/9fdd800a915b5ac3f0e1b64807de8b09 to your computer and use it in GitHub Desktop.
/**
* 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