The most likely cause is that your custom
useEffect
method - which you haven't shown - is calling the callback function passed as the first parameter without passing any arguments. You then try to call
preventDefault
on the first argument, which will be
undefined
.
You'll either need to fix your
useEffect
method to pass the correct value to the callback, or change the callback so that it doesn't try to use an undefined parameter.
For example:
const trackItem = (e) => {
if (e && e.preventDefault) { e.preventDefault(); }
...