Ecommerce Shopify WordPress Discussion

Add a react component into elementor and allow it to dinamycally get data

Im trying to replace an elementor widget by one i custom made myself using react, in the code i have below im passing the array as an example since i thought getting it dynamically would be similar, im using tailwind for the react component. the fields that im trying to get from the post types are the same as the ones represented by the mockItems Im trying to find any step by step but it all seems to be missing some crucial steps that i don't know. Sorry if the answer is obvious or more straightforward than i think it is. This is the code for my react component import React, { useState } from 'react'; import { useSpringCarousel } from 'react-spring-carousel'; const Carousel2 = () => { const mockItems = [ { id: 'item-1', title: 'slide 1', image: 'https://via.placeholder.com/80x80', loremIpsum: 'Short Lorem Ipsum.', number: 123, twoWordLorem: 'Two Word', }, { id: 'item-2', title: 'slide 2', image: 'https://via.placeholder.com/80x80', loremIpsum: 'Long Lorem Ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', number: 456, twoWordLorem: 'Another Slide', }, { id: 'item-3', title: 'slide 3', image: 'https://via.placeholder.com/80x80', loremIpsum: 'Long Lorem Ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Long Lorem Ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.," // Example of a very long Lorem Ipsum', number: 789, twoWordLorem: 'Dynamic Content', }, ]; const [currentSlide, setCurrentSlide] = useState(mockItems[0].id); const { carouselFragment, slideToPrevItem, slideToNextItem, useListenToCustomEvent, } = useSpringCarousel({ itemsPerSlide: 3, withLoop: true, initialStartingPosition: 'center', gutter: 24, items: mockItems.map((item) => { return { ...item, renderItem: ( <div key={item.id} className={`grid aspect-[2] w-full place-items-center text-lg pt-[60px] select-none text-black bg-white border-2 border-teal-400 shadow-2xl rounded-md transition-all duration-700 ${ currentSlide === item.id ? 'z-10 scale-150' : '' }`} > <img src={item.image} alt={`Slide ${item.title}`} className="mb-4 shadow-2xl absolute top-[-40px] rounded-full border-teal-400 border-8" /> <p className="text-center">{item.loremIpsum}</p> <p className="font-bold text-teal-600 mb-2">{item.number}</p> <p className="text-sm">{item.twoWordLorem}</p> </div> ), }; }), }); useListenToCustomEvent((event) => { if (event.eventName === 'onSlideStartChange') { setCurrentSlide(event?.nextItem?.id); } }); return ( <div className="py-20 relative"> <button onClick={slideToPrevItem} className="absolute top-1/2 -translate-y-1/2 -translate-x-full left-[10%]"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-6 h-6 mr-10"> <path strokeLinecap="round" strokeLinejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /> </svg> </button> <div className="mx-auto w-[80%] overflow-x-clip py-[4%] relative">{carouselFragment}</div> <button onClick={slideToNextItem} className="absolute top-1/2 -translate-y-1/2 translate-x-full right-[10%]"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-6 h-6 ml-10"> <path strokeLinecap="round" strokeLinejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" /> </svg> </button> </div> ); }; export default Carousel2;
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.