Javascript: Add support for React Hooks

Created on 28 Oct 2018  ·  12Comments  ·  Source: airbnb/javascript

I would suggest to enforce the Rules of Hooks for React v16.7.0-alpha and beyond. A linter plugin is already available under the package eslint-plugin-react-hooks.

react guide change

Most helpful comment

eslint-plugin-react-hooks just hit v1.0.0.

I've been using eslint-config-airbnb for a long time especially for react and would love to see eslint-plugin-react-hooks make its way to the peer deps for all the react hooks goodness 😄

All 12 comments

It’s still an alpha (for only 3-4 days); it’s not safe to rely on in production yet - at least until it’s considered stable by the React team.

Separately, adding an extra plugin to the config is semver-majpr and we’re very unlikely to do it without very good reason and a lot of time and consideration.

@ljharb Thank you for the fast review! I just wanted to raise an issue for tracking the progress of addition, as a reference for curious minds experimenting with the latest APIs.

Even when stable, it’s not a given that this config should include it.

I’m pretty unclear on the wisdom of react relying on a linter rule to ensure a feature is used safely, and I’m hopeful that decision will be revisited before the feature ships.

I’m hopeful that decision will be revisited before the feature ships.

I highly doubt that decision would be revisited unless someone can provide an extraordinary alternative solution very quickly. For this reason I think this item should be tracked very carefully.

From https://reactjs.org/docs/hooks-rules.html#eslint-plugin:

In the future, we intend to include this plugin by default into Create React App and similar toolkits.

If insufficient time is going to be provided for non-Facebook employees to weigh in on new features and decisions, then I’m not sure what the point of calling things “unstable” or “alpha” is. ¯\_(ツ)_/¯

I will try to make it a little more clear: from the very long discussion in https://github.com/reactjs/rfcs/pull/68 there some very well-explained concerns and alternatives but so far nothing seems to be strong enough to counter the tide toward finalization. Any ideas?

Well, it just alpha, not even RC. It is too early, and I think they know it is controversy. And I guess they are promoting their RFC.

If a feature can’t be achieved safely without a linting rule, then a very viable option is always “don’t add the feature”.

I totally agree... The issue is coming from the call order dependency, which is impossible to do static analysis before run-time.

eslint-plugin-react-hooks just hit v1.0.0.

I've been using eslint-config-airbnb for a long time especially for react and would love to see eslint-plugin-react-hooks make its way to the peer deps for all the react hooks goodness 😄

It's in react docs now:

We provide a linter plugin to enforce these rules automatically. We understand these rules might seem limiting or confusing at first, but they are essential to making Hooks work well.

no hooks keep all eslint congig

Was this page helpful?
0 / 5 - 0 ratings

Related issues

progre picture progre  ·  3Comments

zurfyx picture zurfyx  ·  3Comments

felixsanz picture felixsanz  ·  3Comments

kozhevnikov picture kozhevnikov  ·  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  ·  3Comments