Preact compatibility
Does anyone know if there is any reason why this wouldn't work with preact?
From what I've been able to gather it should work just fine, however, when I try to use it it always throws out a : WrappedComponent lacks a function for processing outside click events specified by the handleClickOutside config option. error
Could u paste in the code of how do you try to use this module?
Hey, also had this same issue. I'm pretty sure it's an issue with this module checking if WrappedComponent.prototype.isReactComponent exists, which doesn't exist on preact components
So ended up with a small hack to fix it for myself, by adding a dummy isReactComponent method to the class:
class ColorPicker extends Component {
...
isReactComponent() {}
...
}
export default onClickOutside(ColorPicker);
Can also work on a pr for this, if that's ok
@teevik thanks fam
I'll be honest, this feels like something to offer as "extension" on Preact, not something to address in libraries designed for React? That snippet looks like an excellent thing to "publish". I love preact, but it cuts corners where it can in order to stay tiny, and that is guaranteed to break some libraries through no fault of those libraries.
You could write a class Component extends React.Component with a pass-through constructor, add in that single function, and then export that class with the same Component name but in your own namespace. Now people can import { Component } from 'patched-preact' or something and not have to add the function in every class they write themselves.