React v16.8 arrives with Hooks available in a stable release
The wait is over! React v16.8 is here and it brings Hooks in a stable release! If you missed the hype and you don’t know what we’re talking about, fear not! In this article, we are having a closer look at this new feature.
React v16.8 is live and so is the stable release of Hooks!
This new release brings a couple of important updates and improvements, but the Hooks is definitely the feature that steals the spotlight!
Before we dig deeper into this new feature, let’s have a quick look at the other updates in React v16.8.
- Bail out of rendering on identical values for
useReducerHooks. (@acdlite in #14569)
- Don’t compare the first argument passed to
useCallbackHooks. (@acdlite in #14594)
Object.isalgorithm for comparing
useReducervalues. (@Jessidhia in #14752)
- Support synchronous thenables passed to
React.lazy(). (@gaearon in #14626)
- Render components with Hooks twice in Strict Mode (DEV-only) to match class behavior. (@gaearon in #14654)
- Warn about mismatching Hook order in development. (@threepointone in #14585 and @acdlite in #14591)
- Effect clean-up functions must return either
undefinedor a function. All other values, including
null, are not allowed. @acdlite in #14119
Check out the official changelog for the extensive list of updates.
And now, all aboard the Hooks hype train!
Don’t let me off the Hook, please!
First of all, what exactly are Hooks?
React Hooks a new feature that lets you use state and other React features without writing a class and it’s React solution to with issues like giant components and confusing classes that, as Sophie Alpert has mentioned, are confusing both for humans and machines!
But what is so special about Hooks, anyway?
Hooks let you organize the logic *inside* a component into reusable isolated units by applying the React philosophy, explicit data flow and composition, inside a component, rather than just between the components.
Although the concept is very interesting and it definitely has the potential to reduce the number of concepts you need to maneuver around when writing React applications, it is totally understandable that some of you may have some concerns about the new features. So, let me address some of your skepticism.
First of all, the introduction of Hooks does not mean that classes are getting replaced! In fact, Hooks work side-by-side with the existing code so you can adopt them gradually if you wish to. Have a look here to find out more about React’s gradual adoption strategy.
Hooks are also 100% backward-compatible since they don’t contain any breaking changes.
Now, if you cannot wait to start using Hooks, head over to the official overview and learn all you need to know about this new feature!