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

211
Views
Pasar un número a un componente

Estoy tratando de pasar un número a un componente React pero se analiza como una cadena ( jsfiddle ). ¿Cómo hago que React entienda que estoy pasando un número? ¿Debo convertir la cadena a un número en el componente?

 var Rectangle = React.createClass({ render: function() { return <div> <div>{this.props.intValue + 10}</div> <div>{this.props.stringValue + 10}</div> </div>; } }); React.render(<Rectangle intValue="10" stringValue="Hello" /> , document.getElementById('container'));
 <script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script> <div id="container"> <!-- This element's contents will be replaced with your component. --> </div>

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Parece que en el caso de números enteros (y en realidad también para cadenas) debería pasar los números a través de {} así:

React.render(<Rectangle intValue={10} stringValue={"Hello"} />, document.getElementById('container'));

over 4 years ago · Santiago Trujillo Report

0

Puedes usar:

 <MyComponent param1={10} param2={20} />

O:

 <MyComponent {...{param1: 10, param2: 20}} />
over 4 years ago · Santiago Trujillo 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!