SHARE
TWEET

Untitled

a guest May 25th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {Component} from "react";
  2.  
  3. const BoilingVerdict = (props) => {
  4.   if(props.celius >= 100) {
  5.     return <p>The water would boil!</p>
  6.   }
  7.  
  8.   return <p>The water would not boil!</p>
  9. };
  10.  
  11. class Calculator extends Component {
  12.   state = {
  13.     temperauture: "",
  14.     scale: "c"
  15.   }
  16.  
  17.   handleCelsiusChange = (temperature) => {
  18.     this.setState({scale: "f", temperature})
  19.   }
  20.  
  21.   handleFahrenheitChange = (temperature) => {
  22.     this.setState({scale: "f", temperature})
  23.   }
  24.  
  25.   render() {
  26.     const scale = this.state.scale;
  27.     const temperature = this.state.temperature;
  28.     const celsius = scale === "f" ? tryConvert(temperature, toCelsius) : temperature;
  29.     const fahrenheit = scale === "c" ? tryconvert(temperature, toFahrenheit) : temperature;
  30.    
  31.     return (
  32.       <Temperature
  33.         scale="c"
  34.         onTemperatureChange={this.handleCelsiusChange}
  35.         temperature={celsius} />
  36.       <Temperature
  37.         onTemperauteChange={this.hendleFahrenheitChange}
  38.         scale="f"
  39.         temperature={fahrenheit} />
  40.       <BoilingVerdict
  41.         celsius={parseFloat(temperature}) />
  42.     );
  43.   }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top