Skip to content

Commit 641a6ec

Browse files
committed
Improve the class component defaultProps example
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.
1 parent e30c87c commit 641a6ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export class Greet extends React.Component<Props> {
445445
const { name } = this.props;
446446
return <div>Hello ${name.toUpperCase()}!</div>;
447447
}
448-
static defaultProps = { name: 'world' };
448+
static defaultProps: Partial<Props> = { name: 'world' };
449449
}
450450

451451
// Type-checks! No type assertions needed!

0 commit comments

Comments
 (0)