extend supported component decorators
mbest opened this issue Β· comments
Currently only React.forwardRef
and React.memo
are supported. If using Mobx-React, the observer HOC triggers this error and requires overrides in the file. It would be good if we could add observer
to the allowed list.
Hey @mbest, thanks for reporting this π
It seems like a valid use case to be able to allow this. However, I'd like to make the rule more lenient by default - not everyone may use the observer
function from MobX.
Thus, I suggest making it opt-in by exposing a configurable list of function names that should be treated as HOCs.
I am quite busy with my university at the moment, so it may take a while for me to add this functionality. If you (or anyone else) have some spare time, feel free to raise an MR π
I realized that I can work around the rule by giving the inner function a component-style name:
export const WebsiteFilterToggle = observer(function WebsiteFilterToggle() {
const [state, setstate] = useState(initialState);
...
});
Still, I'll look into submitting a PR for configurable HOCs.
Oh, right, I forgot to mention that workaround π Good catch
Thanks for mentioning it π