[import React, { useEffect, useState } from 'react';
import './Row.css';
import axios from './axios'
function Row({ title,fetchUrl, isLargeRow = false}) {
const [movies, setMovies] = useState([]);
const base_url = "https://image.tmdb.org/t/p/original/"
useEffect(() => {
async function fetchData() {
const request = await axios.get(fetchUrl);
setMovies(request.data.results);
return request;
}
fetchData();
}, [fetchUrl[]][1]);
// console.log(movies);
return (
<div className='row'>
<h2>{title}</h2>
{movies.map((movie) => (
<img src={`${base_url}${
isLargeRow ? movie.poster_path : movie.backdrop_path
}`} alt={movie.name}
/>
))}
</div>
);
}
export default Row
I am getting an error
Warning: Each child in a list should have a unique "key" prop.
Check the render method of Row. See https://reactjs.org/link/warning-keys for more information.
at img
at Row (http://localhost:3000/static/js/bundle.js:596:5)
at div
at HomeScreen
at div
at App
at Provider (http://localhost:3000/static/js/bundle.js:43095:5)
In dependency of useEffect just give fetchUrl like
like this
}, [fetchUrl]);