Closed 1ncredibleM1nd closed 10 months ago
In documentation you wrote, that for using SortableList with custom component need using forwardRef I tried to write this code:
<SortableList onSortEnd={onSortEnd} className="slider-settings__slides list" draggedItemClassName="dragged" > {items.map((st, index) => ( <SortableItem key={st.id}> <SortableImage ref={ref} id={st.id} index={index} src={st.src} /> </SortableItem> ))} </SortableList>
Component SortableImage
const SortableImage = forwardRef(({ id, src, index, ref }: IProps) => { return ( <div key={id} ref={ref} className="slider-settings__wrapper"> <div className="slider-settings__slide"> <button className="slider-settings__dnd-btn dragHandle"> <img src={drag} alt="" /> </button> <button className="slider-settings__delete-btn"> <img src={close} alt="" /> </button> <img className="slider-settings__img" src={src} /> </div> <p className="slider-settings__count">{++index}</p> </div> ); });
Help me
What is not working with this?
All working, my mistake... Refs have been dropped to props, sorry. Close issue, please
In documentation you wrote, that for using SortableList with custom component need using forwardRef I tried to write this code:
Component SortableImage
Help me