Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react state lifting

class Calculator extends React.Component {
  constructor(props) {
    super(props);
    this.handleChange = this.handleChange.bind(this);
    this.state = {temperature: ''};
  }

  handleChange(e) {
    this.setState({temperature: e.target.value});
  }

  render() {
    const temperature = this.state.temperature;
    return (
      <fieldset>
        <legend>Enter temperature in Celsius:</legend>
        <input
          value={temperature}
          onChange={this.handleChange} />
        <BoilingVerdict
          celsius={parseFloat(temperature)} />
      </fieldset>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: difference between =, == and === in javascript 
Javascript :: js compiler 
Javascript :: Routes & GET Requests 
Javascript :: how to set array in javascript 
Javascript :: bind method in js 
Javascript :: functions and variables javascript 
Javascript :: what is heap in javascript 
Javascript :: run react native with debugger breakpoint 
Javascript :: new function javascript 
Javascript :: add value to object 
Javascript :: node.js modules 
Javascript :: how to usestate in react 
Javascript :: javascript 00:00:00 / 00:00:00 clock 
Javascript :: filter a table based on combibox in js 
Javascript :: date and month are swapping in angular 
Javascript :: delete class through the dom 
Javascript :: javascript program name 
Javascript :: changing parent function states in child function 
Javascript :: find smallest interval in array javascript 
Javascript :: how to use browser sync in vuetify 
Javascript :: boxcolliion code javascript 
Javascript :: jhipster success alert 
Javascript :: proet javascript web 
Javascript :: nodejs json data serving 
Javascript :: ui5 React bind element 
Javascript :: asciicinema 
Javascript :: find all input elements in a form 
Javascript :: bookshelfjs npm 
Javascript :: jstree select all visible node only 
Javascript :: angry professor javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =