I'm using a react select to filter my movies by categories but my function is not working, when I click on the element to filter, it delete all the movies on the UI
This is my Filter components :
import React from 'react';
import Select from 'react-select';
const CategoriesFilter = ({categories, filterMovie}) => {
const options = categories.map((c) => ({ value: c, label: c }));
return (
<div>
<Select
className="select-option"
options={options}
placeholder={"type something"}
onChange={filterMovie}
/>
</div>
)
}
export default CategoriesFilter;
This is my filter function and state from my APP js
const [moviesList, setMoviesList] = useState(MoviesData);
const filterMovie = (category) => {
const filterMovie = MoviesData.filter((movie)=> movie.category === category);
setMoviesList(filterMovie);
}
Where do you think the problem comes from?
Thank you guys