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

141
Visualizações
How can I solve - Uncaught TypeError: removeIndividualBook is not a function?

I have removeIndividualBook in index.js which removes individual book. This functionality was working fine from Book component.

I am creating new component Quantity and trying to access removeIndividualBook there. I am passing removeIndividualBook as prop from index.js to Book.js to Quantity.js.

In Quantity.js I am getting Uncaught TypeError: removeIndividualBook is not a function

index.js

  // Remove Individual book
  const removeIndividualBook = (id) => {
    const updatedBookData = booksData.filter((book) => {
      return book.id !== id;
    });
    setBooksData(updatedBookData);
  };

<Book key={index} {...book} removeIndividualBook={removeIndividualBook}></Book>

Book.js

const Book = ({description,id,removeIndividualBook}) => {
  const clickHandler = () => {
    alert(description);
  };
      <Quantity id={id} removeIndividualBook={removeIndividualBook} />

Quantity.js

const Quantity = (id, removeIndividualBook) => {const Quantity = (id, removeIndividualBook) => {}


return (
    <>
      <button
        className="button" onClick={() => removeIndividualBook(id)}> ------>>> Error
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

As I can see in your Quantity.js component, your syntax is not good. It should be

const Quantity = ({id, removeIndividualBook}) => {

return (
    <>
      <button
        className="button" onClick={() => removeIndividualBook(id)}>
...
)

the props should be wrapped in { } (destructed). I think that is the problem you are providing.

about 4 years ago · Juan Pablo Isaza Relatório

0

I reproduced somehow your components with a code snippet.

I think your problem is because you are not destructuring props correctly, (id, removeIndividualBook), they should be ({id, removeIndividualBook}).

Here is the link that you can see that it works properly:

Code Snippet Link

Hope this solves your issue!

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