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

231
Visualizações
I am trying to use map in my react redux app. but after using useDispatch, the console is showing error

I am working on an app, but I am getting errors in the console. I am sending the picture of the error, along with the code which causes the error. could anyone tell, me what causes this problem?

import React from 'react';
import { useSelector, shallowEqual } from 'react-redux';
import AddBook from './form';
import SingleBook from './singleBook';


const DisplayBooks = () => {
  const books = useSelector((state) => state.booksArray, shallowEqual);

  return (
    <div className="book-list">
      {books.map((book) => <SingleBook key={book.id} title={book.title} author={book.author} />)}
      <AddBook />
    </div>
  )
};

export default DisplayBooks;

Below I have pasted the console image.

image of the console

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think so this line of code is causing the problem

const books = useSelector((state) => state.booksArray, shallowEqual)

Change it to,

const books = useSelector((state) => state.booksArray)
console.log(books) -> to check whether the books is an array or not
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