Skip to content

Tutorial page "Lifting State Up" demo can give incorrect boiling verdict #1983

Description

@PeterVermont

Because the Boiling verdict uses the temperature in celsius , if the user puts in fahrenheit 211.9999 this will incorrectly report that it will boil. This is because the conversion to celsius is limited to 3 digits and gets rounded up to 100.

image

A fix for this is to change BoilingVerdict to accept scale and temperature and the code to do a slightly different check for each:

function BoilingVerdict(props) {
  if (props.scale === 'c' ? props.temperature >= 100 : props.temperature >= 212) {
    return <p>The water would boil.</p>;
  }
  return <p>The water would not boil.</p>;
}

        <BoilingVerdict
          scale={this.state.scale}
          temperature={this.state.temperature} 
          />

image

I know that I could do a fork and pull request but this is about as far as my interest in this subject goes so anyone else is free to fix this admittedly tiny issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions