Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda