How to build the react drag-and-drop component?

directly writes a component of drag-and-drop sorting. The main principle is that
reshuffles each children with a shell through this.props.children, and then the shell is draggable=true, but because the component determined by onDrop determines the element in children every time, I can"t control the id, of the children element, so the sorting is an error, so I added a top to the shell, a transparent layer of zindex=99, and added a sorting attribute to this top, but this way, because it won"t penetrate, All the response events of children have failed. What should I do with (hover),?

  createChild(){
    if(!this.state.children) return; 
    var tmp = [];
    for (let j = 0; j < this.state.children.length; jPP) {
        if (this.state.children[j].props.dragable) {
          tmp.push(<div className={style.ChildBox} key={"dropBox"+j} id={j}  
            draggable={true}      //
            onDragStart={this.onDragStart}    //  Fun
            onDragOver={this.onDragOver}>   //Fun
          <div className={style.fakeMask} id={j}>   //ID 
            </div>{this.state.children[j]}
          </div>)
        } else {
          tmp.push(<div className={style.ChildBox} key={"dropBox"+j} id={j}><div className={style.fakeMask} id={j}></div>{this.state.children[j]}</div>)
        }
        
    }
    return tmp
  }
onDrop(event){
    this.props.onSort(event.dataTransfer.getData("id"),event.target.id);    //
}

fakeMask is what I call the transparent top, plus the sort id so that I can return the sort sequence to the parent component.
if you do not add it, each time onDrop determines that {this.state.children [j]} cannot get the sort;
the parent component gets the sort ID, and then rechanges the positions in the data array by sorting ID, and then renders the data.

parent component:

onSort(dragindex,dropindex){
    let newArray = this.insertArray(this.state.dataArray,parseInt(dragindex),parseInt(dropindex));    //
    this.setState({
      dataArray:newArray,
    });
  }
insertArray(arr, item, index) {
    var t = arr[item];
    arr.splice(item, 1);
    return arr.slice(0,index).concat(t, arr.slice(index));
  }
Apr.04,2021

Why not use off-the-shelf components. react-dnd or react-draggable .


found a solution. When onDragOver, change fakeMask to 100% / 100%, otherwise do not display

onDragOver(event){
    this.setState({
      DragOver:true,
    })
    event.preventDefault()
 }
createChild(){
    if(!this.state.children) return; 
    var tmp = [];
    for (let j = 0; j < this.state.children.length; jPP) {
        if (this.state.children[j].props.dragable) {
          tmp.push(<div className={style.ChildBox} key={'dropBox'+j} id={j}  
            draggable={true}      //
            onDragStart={this.onDragStart.bind(this,j)}    //  Fun
            onDragEnd={this.onDragEnd}
            onDragOver={this.onDragOver}
            >   
          <div className={[style.fakeMask,this.state.DragOver?style.actmask:''].join(' ')} id={j}></div>
          {this.state.children[j]}
          </div>)
        } else {
          tmp.push(<div className={style.ChildBox} key={'dropBox'+j} id={j}><div className={style.fakeMask} id={j}></div>{this.state.children[j]}</div>)
        }
        
    }
    return tmp
  }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35bec-2b320.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35bec-2b320.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?