Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
In React why don't people pass props/state directly to children but create a temporary const variable?

For example, why not use value={this.props.temperature} in the example below? state has a similar usage.

Is this just to be functional, so that the underlying components cannot modify the state of the upper layer? Is it a restriction or a convention?

render() {
    const temperature = this.props.temperature;
    const scale = this.props.scale;
    return (
      <fieldset>
        <legend>Enter temperature in {scaleNames[scale]}:</legend>
        <input value={temperature}
               onChange={this.handleChange} />
      </fieldset>
    );
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is just a syntactic sugar to use a const here instead of the long form this.props.something, It also gives you the ability to edit it in one place, instead of editing it in every place (e.g changing the name of the prop)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!