mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 04:19:45 +00:00
Добавить в Слайдер поддержку передачи изображений в пропсы
This commit is contained in:
1 parent
303fecec47
commit
4978c36070
1 file changed
+16
-5
@@ -2,23 +2,34 @@ import { useEffect, useState, createContext } from 'react';
|
||||
|
||||
import Arrows from './components/Arrows';
|
||||
import SlidesList from './components/SlidesList';
|
||||
import Dots from './components/Dots';
|
||||
// import Dots from './components/Dots';
|
||||
|
||||
import { getMedia } from '../../api';
|
||||
import './Slider.styles.scss';
|
||||
|
||||
export const SliderContext = createContext();
|
||||
|
||||
function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
|
||||
const [mediaList, setMediaList] = useState([]);
|
||||
function Slider({ autoPlay = 0, autoPlayTime = 0, images = false }) {
|
||||
const [mediaList, setMediaList] = useState([images]);
|
||||
const [slide, setSlide] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
const newMediaList = await getMedia('gallery');
|
||||
let newMediaList;
|
||||
|
||||
if (images) {
|
||||
newMediaList = images.map((value, key) => {
|
||||
return { id: key, src: value };
|
||||
});
|
||||
} else {
|
||||
newMediaList = await getMedia('gallery');
|
||||
}
|
||||
|
||||
setMediaList(newMediaList);
|
||||
console.log('sliderMedia', newMediaList)
|
||||
console.log('sliderMedia', newMediaList);
|
||||
};
|
||||
|
||||
console.log(images);
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in new issue
Block a user