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

107
Views
How to have javascript inside of react.js

I am building a React.JS website and I am not entirely sure how to implement a section of JavaScript inside of my html. In normal HTML you would put the script inside of these tags:

<Script></Script>

But with react.js

function App() {
  return (
    <div>
        <button onlick='log()'>Log</button>
        <script>
            Log() = Console.log('Hello')
        </Script>
    </div>
  );
}

export default App;

Something like this will not work. How am i able to run a script this way?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Please learn how React works and how events work specifically

A basic example:

function App() {
  const log = () => console.log('Hello')

  return <button onClick={log}>Log</button>
}

export default App;
about 4 years ago · Juan Pablo Isaza Report

0

try this

 function App() {
const log =()=> {console.log('Hello')}
  return (
    <div>
        <button onClick={()=>log()}>Log</button>
     
    </div>
  );
}

export default App;

more information: https://reactjs.org/docs/handling-events.html

about 4 years ago · Juan Pablo Isaza Report

0

ReactJs Docs will be your friend here but basically you can run your javascript code inside your function component before your return statement

Here is a codesandbox link example

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!