Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

StatefulHello passes npm run test #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ interface State {
class Hello extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { currentEnthusiasm: props.enthusiasmLevel || 1 };
this.state = { currentEnthusiasm: props.enthusiasmLevel == null ? 1 : props.enthusiasmLevel };
Copy link

@gasparsigma gasparsigma Feb 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enthusiasm level cannot be null. It can be number or undefined.
You can check for strict comparison === undefined instead.

}

onIncrement = () => this.updateEnthusiasm(this.state.currentEnthusiasm + 1);
Expand Down