search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Listen for Event Resizing on UseEffect

Asked by Anonymous
7 months ago.

As title says, i would like to avoid setStates in onEventResizing because it gives some issues, but i need to triggher an useEffect. What can I do?

Answer posted by Dan Letecky [DayPilot]
7 months ago.

I would recommend handling the logic directly in the onEventResizing event handler.

The typical action would be to notify the server or to ask for a confirmation. These actions are not typical “state changes” where useEffect makes most sense.

If you want to trigger useEffect you would have to change a state property. It could look like this:

const [eventResizeArgs, setEventResizeArgs] = useState(null);

useEffect(() => {
    if (eventResizeArgs !== null) {
        // ... process the event
    }
}, [eventResizeArgs]);

const handleEventResize = useCallback(args => {
    setEventResizeArgs(args);
}, []);

// ...

<DayPilotScheduler
    onEventResize={handleEventResize}
    // ...
/>
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.