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

228
Views
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 answers
Answer question

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 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!