Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend supported component decorators #27

Open
mbest opened this issue Apr 23, 2020 · 3 comments
Open

extend supported component decorators #27

mbest opened this issue Apr 23, 2020 · 3 comments

Comments

@mbest
Copy link

mbest commented Apr 23, 2020

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.

@Gelio
Copy link
Owner

Gelio commented Apr 27, 2020

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 😄

@mbest
Copy link
Author

mbest commented Apr 28, 2020

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.

@Gelio
Copy link
Owner

Gelio commented Apr 28, 2020

Oh, right, I forgot to mention that workaround 😄 Good catch

Thanks for mentioning it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants