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

336
Views
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
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!