I am attempting to create a text carousel that displays data from an array one at a time. I have stored the data in an array and now I want to implement a button that allows me to navigate through the array entries. However, I am facing issues finding a solution for this. Can anyone help?
.jsx
import React from 'react'
import './CambioMesPeriodo.css';
import { useState } from "react";
export default function CambioMesPeriodo() {
const slidesArray = [
{id: 1,
Sup: 'Texto Superior 1',
Inf: 'Texto Inferior 1'},
{id: 2,
Sup: 'Texto Superior 2',
Inf: 'Texto Inferior 2'},
{id: 3,
Sup: 'Texto Superior 3',
Inf: 'Texto Inferior 3'} ]
const [slide] = useState(slidesArray);
var array = 1;
const values = slidesArray.map(object => object.id)
let validSlide = slide.filter(slides => slides.id === (values,array))
return (
<div className="slideshow-container">
<div>
<p> {validSlide[0].Sup} </p>
<p> {validSlide[0].Inf} </p>
</div>
{/* <div> {values.map(name => <h2>{name}</h2>)} </div> */}
<button >Adelante</button>
</div>
)}
.css
/* Slideshow container */
.slideshow-container {
position: relative;
background: #898989;
border-radius: 10px;
width: 310px;
height: 65px;}
Displayed on Web: here is the image description