React text rendering issue

I use Array.map and I style this text and it’s show both style and not styled text. What happen can someone help me?
13 Replies
Jochem
Jochem2y ago
without seeing your code, there's no useful way to answer check #How To Ask Good Questions for tips
ChengXiao
ChengXiaoOP2y ago
Jochem
Jochem2y ago
Can you paste the code instead of sharing screenshots photos of your monitor?
ChengXiao
ChengXiaoOP2y ago
{data.map((item, index) => { return ( <div className={index === activeIndex ? "slides active" : "slides"}> <img src={item.image} alt="img" key={index.id} /> </div> ); })} {data.map((info, index) => { return ( <div className="slide-info"> <h4 className={ index === activeIndex ? info.availableActive : info.availableStyle } > {info.available} </h4> <h3 className={ index === activeIndex ? info.titleActive : info.titleStyle } > {info.title} </h3> <button className={index === activeIndex ? info.btnActive : info.btnStyle} > {info.btn} </button> </div> ); })} <div className="cloud-bg"> <img src={cloud1} alt="cloud" style={{ "--i": "1" }} /> <img src={cloud2} alt="cloud" style={{ "--i": "2" }} /> <img src={cloud3} alt="cloud" style={{ "--i": "3" }} /> <img src={cloud4} alt="cloud" style={{ "--i": "4" }} /> <img src={cloud5} alt="cloud" style={{ "--i": "5" }} /> </div> </div> ); }; export default SliderCard; import slide1 from "./assets/slide-01.jpg"; import slide2 from "./assets/slide-02.jpg"; import slide3 from "./assets/slide-03.jpg"; export const MAINSLIDE = [ { id: 11, image: slide1, title: "Elden Ring", titleStyle: ["animatefadeInUp", "animatefadeOut"], titleActive: "animatefadeInUp", available: "Available ON PS5", availableStyle: ["animatefadeInDown", "animatefadeOut"], availableActive: "animatefadeInDown", btn: "Get Now", btnStyle: ["animatezoomIn", "animatefadeOut"], btnActive: "animatezoomIn", }, { id: 22, image: slide2, title: "The Last of Us Part 2", titleStyle: ["animatelightSpeedInRight", "animatefadeOut"], titleActive: "animatelightSpeedInRight", available: "Available Now", availableStyle: ["animaterollIn", "animatefadeOut"], availableActive: "animaterollIn", btn: "Get Now", btnStyle: ["animatefadeInUpBig", "animatefadeOut"], btnActive: "animatefadeInUpBig", }, { id: 33, image: slide3, title: "Nier:Automata", titleStyle: ["animaterotateInUpRight", "animatefadeOut"], titleActive: "animaterotateInUpRight", available: "Top Rated", availableStyle: ["animaterotateInDownLeft", "animatefadeOut"], availableActive: "animaterotateInDownLeft", btn: "Get Now", btnStyle: ["animaterotateIn", "animatefadeOut"], btnActive: "animate__rotateIn", }, ];
Jochem
Jochem2y ago
Please read the thread I linked 😦 it tells you how to share code that's readable. Discord formatting is messing it up into an unreadable mess
ChengXiao
ChengXiaoOP2y ago
Srry 😅
Jochem
Jochem2y ago
I think you missed a couple of files that might be important, especially the slider.css
Jochem
Jochem2y ago
Jochem
Jochem2y ago
I think the issue might be that you're trying to set className to an array, which doesn't work. I can't test that though, because while the code is visible in the stackblitz, it doesn't actually run easiest test would be to change these lines in mainslide.js
titleStyle: ['animate__lightSpeedInRight', 'animate__fadeOut'],
titleStyle: ['animate__lightSpeedInRight', 'animate__fadeOut'],
to
titleStyle: 'animate__lightSpeedInRight animate__fadeOut',
titleStyle: 'animate__lightSpeedInRight animate__fadeOut',
(note the removal of []) and then of course for btnStyle and availableStyle as well
ChengXiao
ChengXiaoOP2y ago
It’s working tysm 🫶
Jochem
Jochem2y ago
Np, glad to help
Want results from more Discord servers?
Add your server