Oddly enough, the two examples below are not equal as I thought they would be.
window.addEventListener(
'resize',
this.forceUpdate.bind(this)
);
// throws error
window.addEventListener(
'resize',
() => this.forceUpdate()
);
// works fine
The error is as follows:
Error: Invariant Violation: enqueueCallback(...): You called `setProps`, `replaceProps`, `setState`, `replaceState`, or `forceUpdate` with a callback that isn't callable.
I'm assuming that is because the function as assuming an optional callback. But I would expect your code to do a typeof check, and not just a defined check. Can we change it to do a typeof fn === 'function' check? I can submit a PR.