reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.06k stars 7.56k forks source link

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

Open PeterVermont opened 5 years ago

PeterVermont commented 5 years ago

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.

kambleaa007 commented 5 years ago

I observed that, Now even temp in Celsius is 100, still its showing not boil, its wrong, image

its wrong, image

its right, image

image

any quick fix in code.

kambleaa007 commented 5 years ago

created PR https://github.com/reactjs/reactjs.org/pull/1989 Have a look, Suggest any changes if needed

dptole commented 4 years ago

That is not the only problem with that page

image

In Elm

image

https://ellie-app.com/85gDTH7H5zBa1