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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.