I have a function that fetches more fields from an api when an onPopUpScroll event is triggered. I need to pass an event object to the lodash debounce function but it doesnt work I get an error. This is what I first had:
function loadMoreUsers = (e) => {
e.persist();
const {target} = e;
// fetch data from api and also use target properties
}
const loadMore = debounce(loadMoreUsers, 3000); // used lodash debounce
// The component
<Select onPopupScroll={loadMore}>
// Options
</Select>
I get this error:
This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property `target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
It is pointing to line const {target} = e. I think it might be because debounce has its own event object that its passing but I need to pass the event object from the select component thru the debounce function