A React Image Slider component that fetches images from a given URL and allows users to navigate through the images using next and previous buttons.
- Fetches images from a specified URL
- Allows navigation between images using next and previous buttons
- Displays loading and error messages
- Customizable number of images to fetch and initial page number
- Circle indicators to show the current slide
-
Clone the repository:
git clone https://github.com/Piyushchannawar/React-Mini-Projects.git cd Image-Slider
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173
.
-
Import the
ImageSlider
component in your React application:import ImageSlider from './ImageSlider';
-
Use the component in your application, passing the required
url
prop:const App = () => { return ( <div> <h1>Image Slider</h1> <ImageSlider url="https://example.com/api/images" limit={5} page={1} /> </div> ); }; export default App;
url
(string): The URL to fetch images from.limit
(number): The number of images to fetch. Default is 5.page
(number): The initial page number to fetch images from. Default is 1.