React

Early thoughts on the proposed React Hooks API

RCT

The React team recently proposed Hooks, a new API for using state and other React features without writing a class component. We have not touched it in any client work yet — it is still a proposal, not a stable release — but a few of us spent an afternoon playing with the early builds to get a real feel for it beyond just reading the RFC discussion.

The appeal is real: a lot of our class components accumulate awkward lifecycle-method logic that is really about one concern (fetching data, subscribing to an event) but ends up split across `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount`. Hooks let that logic live together in one place. `useState` in particular removes a surprising amount of ceremony compared to `this.setState` and constructor bindings, and a small component we ported over during the afternoon experiment shrank noticeably once its scattered lifecycle logic could be expressed as a single, self-contained hook.

What still gives us pause

The proposal is genuinely still in flux, and a couple of the patterns we tried during the experiment — particularly around dependency arrays for effects — required more careful thought than the equivalent class-based lifecycle methods did, since it is easy to accidentally omit something an effect actually depends on and get subtly incorrect behavior with no immediate error to flag it. We expect the eventual documentation and tooling around this to improve significantly before a stable release, but it is a real learning curve worth being honest about rather than presenting Hooks as a strictly simpler replacement for what came before.

We will wait for it to land in a stable release before recommending it for client work, but if it ships close to what has been proposed, we expect it to change how we write React day to day, and we are keeping an eye on the RFC discussion closely enough that we do not expect to be caught off guard whenever that stable release actually arrives.

How we are preparing the team ahead of a stable release

Rather than waiting for a stable release and then scrambling to get the team up to speed, we have started a recurring internal lunch-and-learn covering React proposals and RFCs generally, using Hooks as the first real case study given how significant a change it represents. The goal is less about mastering Hooks specifically before they are stable and more about building a habit of tracking upstream framework proposals early enough that a major shift like this one does not arrive as a surprise once it ships.

What existing class-based code would need to change

We spent part of the afternoon experiment specifically thinking through what a gradual migration path would look like for our existing class-component codebases, since the proposal as written does not require rewriting everything at once — Hooks and class components can coexist in the same codebase, which matters a great deal for any team with a substantial existing investment in class components. Assuming that compatibility promise holds through to a stable release, migration is likely to be an opportunistic, file-by-file process on our projects rather than a dedicated rewrite effort, which is a meaningfully lower-risk path than a hard cutover would be.

← Back to the journal

Have a project in mind?
Let’s talk.

Tell us where you are and where you want to go. We'll map the fastest route between the two.

Currently accepting new clients