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

93
Views
Delete item from specific column react beautiful DnD

I’m trying to delete an item from the specific column that it is in, and render the component so it will disappear immediately.

in the application I have 4 columns and orders that are fetched from an api

this is the useState and useEffect that I have created so far

const [orders, setOrders] = useState([]);
const [columns, setColumns] = useState([]);
const [columnsCopy, setColumnsCopy] = useState([]);
    useEffect(() => {
        props.fetchOrder(setOrders)
    },[])

    console.log(orders);
    
    useEffect( () => {
       setColumns(() => {
        return {  
                newOrder:{  
                    name: "Requested",
                    items: orders,
                },
                inProgres: {
                    name: "In Progres",
                    items: [],
                  },
                finished: {
                    name: "Finished",
                    items: [],
                  },
                deliverd: {
                    name: "Deliverd",
                    items: [],
                  }, 
            }})
    console.log(columns)
    }, [orders]);

    useEffect( () => {
        setColumnsCopy((prevState) => {
         return {
             ...prevState,
                 ...columns,   
              }})
    }, [columns]);
    
    console.log(columnsCopy)

and this is the deleteItem function

const deleteItem = ( item, columnsCopy, setColumnsCopy) => {
        const itemId = item._id
        const itemsArray = [columnsCopy];
        itemsArray.splice(item.index , 1);
        setColumnsCopy((prevState) => {
            return {
                 ...prevState,
                ...itemsArray
            }
        })
        dispatch(deleteOrder(itemId));
    console.log(itemId);
};

so what is happening so far the items are being deleted but the component doesn’t change, only when I refresh the page the item has disappeared. Also all of the orders comes back to the first column.

so what do I do to render the component correctly and that the orders will keep their positions?

Thank you in advance

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!