Search code examples
reactjsfullcalendardrag

React full calendar dragging save to state


Hello i use dragging in full calendar and i save events in a state but it duplicates the event in frontend, see example here: https://codesandbox.io/s/fullcalendar-dragging-6js74

how can i store the event in the state without duplicating,

i think it shows one from the state and one from the calendar it self but i need to show only state one because i also store events added on click and on select in the same state.

any solutions please?


Solution

  • You're right about it adding one event from the state and one from the drop operation.

    My suggestion would be to handle the eventReceive callback instead of the "drop" callback. In eventReceive you get you direct access to the event object added to the calendar - that way you can then delete that event (using the event's remove method, once you've also added it to the state.