import React, { useEffect } from "react";
import { movieAction } from "../redux/actions/movieAction";
import { useDispatch, useSelector } from "react-redux/es/exports";
import Banner from "../components/Banner";
import MovieSlide from "../components/MovieSlide";
const Home = () => {
const dispatch = useDispatch();
const { popularMovies, topRatedMovies, upComingMovies } = useSelector(
(state) => state.movie
);
useEffect(() => {
dispatch(movieAction.getMovies());
}, []);
return (
<div>
{}
{popularMovies.results && <Banner movie={popularMovies.results[0]} />}
<h1>Popular Movie</h1>
<MovieSlide movies={popularMovies} />
<h1>Top Rated Movie</h1>
<MovieSlide movies={topRatedMovies} />
<h1>UpComing Movie</h1>
<MovieSlide movies={upComingMovies} />
</div>
);
};
export default Home;
npm install react-multi-carousel --save
import Carousel from 'react-multi-carousel';
import 'react-multi-carousel/lib/styles.css';
import React from "react";
import Carousel from "react-multi-carousel";
import "react-multi-carousel/lib/styles.css";
const responsive = {
superLargeDesktop: {
breakpoint: { max: 4000, min: 3000 },
items: 5,
},
desktop: {
breakpoint: { max: 3000, min: 1024 },
items: 3,
},
tablet: {
breakpoint: { max: 1024, min: 464 },
items: 2,
},
mobile: {
breakpoint: { max: 464, min: 0 },
items: 1,
},
};
const MovieSlide = ({ movies }) => {
return (
<div>
<Carousel responsive={responsive}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</Carousel>
</div>
);
};
export default MovieSlide;