Skip to content
This repository has been 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

StatefulHello passes npm run test #238

wants to merge 1 commit into from

Conversation

daviddao
Copy link

Although we don't run tests on StatefulHello on the tutorial, it is intended by the authors to pass the same tests as the Hello component. Thus we need to stop converting enthusiasmLevel to 1 when0 is passed in.

Allowing to set `0`, so `StatefulHello` component can pass the same tests as `Hello` component
@@ -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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants