Skip to content

Commit

Permalink
Improve the class component defaultProps example
Browse files Browse the repository at this point in the history
In the current example, we have a type definition for props but do not
make use of it for defaultProps. This can lead to a mismatch between
defaultProps and props.
  • Loading branch information
VanTanev committed Apr 6, 2019
1 parent 1dfda0b commit 6a467f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class Greet extends React.Component<Props> {
const { name } = this.props;
return <div>Hello ${name.toUpperCase()}!</div>;
}
static defaultProps = { name: 'world' };
static defaultProps: Partial<Props> = { name: 'world' };
}

// Type-checks! No type assertions needed!
Expand Down

0 comments on commit 6a467f6

Please sign in to comment.