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

140
Views
Hacer cálculos con la entrada de los usuarios

Estoy tratando de hacer cálculos simples con un nuevo valor en un estado actualizado. Simplemente estoy tratando de dividir la entrada de un usuario, con otro número. Soy un principiante total, ¡así que perdóname por la pregunta novata! Aquí está mi código que no funciona para mí. No hay errores, simplemente no muestra la cifra resultante del cálculo:

 import { useState } from "react"; const Counter = () => { const [area, setArea] = useState(""); const newArea = () => { setArea(area.target.value); }; const deckBoards = (newArea) => { (newArea / 0.145).toFixed(2); }; return ( <div label="Deck"> <h2>Total area of deck</h2> Area <input placeholder="Enter area here" type="text" onChange={newArea} type="number" /> <br /> <h2>Deck boards</h2>Deck boards at 140mm wide : {deckBoards} lineal metres </div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Falta un event en la función newArea y DeckBoards debe ser un area en JSx

Prueba esto

 import { useState } from "react"; const Counter = () => { const [area, setArea] = useState(""); const deckBoards = (newArea) => { // it was missing return statement return (newArea / 0.145).toFixed(2); }; const newArea = (e) => { const value = e.target.value; // Calculate here const calculated = deckBoards(value); // Update value setArea(calculated); }; return ( <div label="Deck"> <h2>Total area of deck</h2> Area <input placeholder="Enter area here" type="text" onChange={newArea} type="number" /> <br /> <h2>Deck boards</h2>Deck boards at 140mm wide : {area} lineal metres </div> ); }
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!