Here is my code for a React Where I am maping an array of objects but get Error [ Expected an assignment or function call and instead saw an expression ] so please help how can I do solve this issue..? In my code I want to map data to bootstrap 4 carousel slider code, in my data I have photo,name,achievement so how can I map 3 of It..!
import React, { useState, useEffect } from "react";
import web from "../../image/nisha.jpg";
import web1 from "../../image/Pooja.jpg";
import web2 from "../../image/6547.jpg";
import { isAutheticated } from "../../auth/helper/index";
import { getTestis } from "../helper/coreapicalls";
import "../../styles.scss";
import ReactReadMoreReadLess from "react-read-more-read-less";
const Testimonial1 = () => {
const [testimonial, setTestimonial] = useState([]);
const [error, seterror] = useState([]);
const [loading, setLoading] = useState(false);
const token = isAutheticated() && isAutheticated().token;
const userId = isAutheticated() && isAutheticated().user.email;
useEffect(() => {
loadTestimonial();
}, []);
const loadTestimonial = () => {
getTestis().then((data) => {
if (data.error) {
seterror(data.error);
} else {
setTestimonial(data);
console.log(data);
}
});
setLoading(true);
};
console.log(testimonial);
return (
<div>
<h1 className="blog_heading">Testimonials</h1>
<div className="testimonial">
<div
id="carouselExampleSlidesOnly"
className="carousel slide"
data-ride="carousel"
>
<div className="carousel-inner active container">
{testimonial.map((testi, index) => {
<div className="carousel-item active" key={index}>
<div className="testimonial_content">
<a href={web}>
<img
src={web}
alt="img"
className="rounded-circle img-fluid "
/>
</a>
<h1>{testi.name}</h1>
<p>
<sup>
<i
className="fa fa-quote-left mr-2"
style={{ fontSize: "14px", color: "#ffca08" }}
aria-hidden="true"
></i>
</sup>
<ReactReadMoreReadLess
charLimit={200}
readMoreText={"Read more ▼"}
readLessText={"Read less ▲"}
readMoreStyle={{ color: "#00ba74", fontSize: "15px" }}
>
{testi.achievement}
</ReactReadMoreReadLess>
</p>
</div>
</div>;
})}
</div>
</div>
</div>
</div>
);
};
export default Testimonial1;
Just replace your map code with this:
testimonial.map((testi, index) => {
return (
<div className="carousel-item active" key={index}>
<div className="testimonial_content">
<a href={web}>
<img
src={web}
alt="img"
className="rounded-circle img-fluid "
/>
</a>
<h1>{testi.name}</h1>
<p>
<sup>
<i
className="fa fa-quote-left mr-2"
style={{ fontSize: "14px", color: "#ffca08" }}
aria-hidden="true"
></i>
</sup>
<ReactReadMoreReadLess
charLimit={200}
readMoreText={"Read more ▼"}
readLessText={"Read less ▲"}
readMoreStyle={{ color: "#00ba74", fontSize: "15px" }}
>
{testi.achievement}
</ReactReadMoreReadLess>
</p>
</div>
</div>;
)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.