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

159
Views
Same exact function syntax only works when copied from external code

I'm following a React tutorial. In the Backdrop.js file, there is a simple function that returns a backdrop and assigns an onClick prop to close an open Modal when one clicks the backdrop.

My code looks absolutely identical to me to the one in the tutorialist's Github repo. Somehow though, when I use my code for the function, the Modal doesn't close when I click the backdrop. However when I copy and paste his code directly from Github, the Modal does close when I click the backdrop.

I have no idea what's going on. As far as I can tell, there are no differences whatsoever between the two pieces of code.

My code:

function Backdrop(props) {
  return <div className='backdrop' onCLick={props.onClick} />;
}

export default Backdrop;

His code:

function Backdrop(props) {
  return <div className='backdrop' onClick={props.onClick} />;
}

export default Backdrop;

I'll even have both functions on the same page and if I comment mine out the app will work as intended, but if I comment his code out it doesn't work anymore. For ex, this works (my code on top commented out):

// function Backdrop(props) {
//   return <div className='backdrop' onCLick={props.onClick} />;
// }

// export default Backdrop;


function Backdrop(props) {
  return <div className='backdrop' onClick={props.onClick} />;
}

export default Backdrop;

But this doesn't:

function Backdrop(props) {
  return <div className='backdrop' onCLick={props.onClick} />;
}

export default Backdrop;


// function Backdrop(props) {
//   return <div className='backdrop' onClick={props.onClick} />;
// }

// export default Backdrop;

I do use the Prettier extension if that makes a difference. Could it mess the formatting somehow in an undetectable way?

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

0

function Backdrop(props) {
  return <div className='backdrop' onCLick={props.onClick} />;
}

export default Backdrop;

In your code is a capital L in "onClick". Change it to a lowercase l to make it work.

If you ever have a similar problem, you can use sites like this.

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!