Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to Save Position of react-draggable objects in react

I am using react-draggable to drag and drop elements. How should I save the elements positions after dragging? I was trying to save the position to the local storage by using onStop and initializing an eventLogger but it's not saving the position. Here is my code example, i am happy to get some help, as i am pretty new in this topic. Thank you very much.

return (
  <DragDropContext onDragEnd={this.onDragEnd} defaultPosition={{ x: 0, y: 0 }} onStop={eventLogger}>
    <Droppable droppableId="droppable" type="droppableItem">
      {(provided, snapshot) => (
        <div
          ref={provided.innerRef}
          style={getListStyle(snapshot.isDraggingOver)}
        >
          {this.state.items.map((item, index) => (
            <Draggable        
              key={item.id} draggableId={item.id} index={index}>
              {(provided, snapshot) => (
                <div>
                  <div
                    ref={provided.innerRef}
                    {...provided.draggableProps}
                    style={getItemStyle(
                      snapshot.isDragging,
                      provided.draggableProps.style
                    )}
                  >
                    {item.content}
                    <span
                      {...provided.dragHandleProps}
                    >
                      Drag
                    </span>
                    <ServiceCommandUnit
                      subItems={item.subItems}
                      type={item.id}
                    />
                  </div>
                  {provided.placeholder}
                </div>
              )}
            </Draggable>
          ))}
          {provided.placeholder}
        </div>
      )}
    </Droppable>
  </DragDropContext>
)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!