Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
Javascript unexpected use of 'event': no restricted-globals error?

I'm building a React calculator that allows the user to type input into the form and it performs the operation, this is what I have so far in my App.js folder

function App() {

const [output ,setOutput]=useState(0);
  const [text, setText]=useState('');


 function Clear(){
    setOutput(0)
  }

  function Subtraction() {
    
    setOutput(Number(output)-Number(text));
    }

  function Addition() {
  setOutput(Number(output)+Number(text));
    }

    function valueOnChange(e){
     setText(event.target.value);
    }
 
  return (
    <main>
    <h2>Calculator for Add & Subtract</h2>
    <input type="Number" placeholder="Enter the number for add and subtract"  onChange={valueOnChange} value={text}/>
   
    <button onClick={Addition} >Add</button>
    <button onClick={Clear} >Clear</button>

     <button  onClick={Subtraction}>Subtract</button>
        <div>
        <span>Result</span>
        <div id="Result">{output}</div>
        </div>

    </main>
  );
}
export default App;

On this line:

`"function valueOnChange(e){
 
setText(event.target.value);" `

is where I'm getting the error. Can anyone help me out? Not sure how to fix it.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda