React Forum
Blog & Guide Responses
Apr 08, 2023 · 04:00 AM

You Might Not Need an Effect - discussion (2023-04-08)

Started by Ari Novak
externaleffectsderived staterender-time derivationcontractsevidenceperformancedraft vs commit

This article tends to provoke strong reactions because it's really about boundaries: what should be derived in render vs synchronized in an effect. I like the argument when it's framed as "stop building invisible control loops" and start naming what changes (draft vs commit, lane transitions, identity boundaries).

Read the article

What are the top 2-3 effects you successfully deleted, and what replaced them? Do you use a draft/commit split to avoid effects during typing, or do you synchronize continuously? How do you keep derived calculations from becoming expensive and hurting interaction performance?

Comments (12)

Back to latest
Hana Saito
Apr 12, 2023 · 12:12 PM

We deleted effects that only existed to keep two pieces of state in sync.

We replaced them with derivation + normalization.

Mei Tan
Apr 18, 2023 · 06:18 PM

Draft/commit split was the biggest effect killer for us. Once you stop treating every keystroke as committed state, you stop needing effects to "repair" state after the fact.

txt
[tips] input draft=q:"rea" reason=typing
[tips] input commit=q:"react" reason=enterKey
Rafael Soto
Apr 28, 2023 · 04:40 AM

We replaced a bunch of sync effects with a single normalized contract object.

Instead of setFoo, setBar, and then an effect to keep them consistent, we store { foo, bar, evidence } and derive the rest from it.

Jun Park
May 06, 2023 · 06:06 AM

Concrete alternative: keep the effect, but make it a strict pattern (one effect, one boundary, one reason).

Deleting effects is great, but if you can't delete it, at least keep it narratable.

Ari Novak
May 08, 2023 · 08:08 AM

Yes. I think the article gets misread as "effects are evil".

The real win is deleting the ones that exist only to patch over duplicated state.

Grace McCoy
May 20, 2023 · 08:20 PM

Docs tie-in: this fits the docs' focus on observable contracts and avoiding hidden orchestration.

Related: State Management and Performance and Rendering.

Nina Kapoor
Jun 18, 2023 · 06:18 PM

Long-form: the expensive derived-work problem is real, but effects aren't the only answer.

We keep derivation cheap by controlling identity: only recompute when a committed identity changes. Draft changes stay local and cheap; committed changes update the contract.

Once identity boundaries are explicit, the derived work stops exploding.

Caleb Price
Aug 21, 2023 · 09:21 PM

Short take: if you have an effect that only calls setState, you probably have duplicated state.

Ibrahim Saleh
Sep 12, 2023 · 12:12 PM

We deleted an effect that synced URL query params into local state.

The replacement was: parse/normalize query into route state, render from that, and let the URL be the single source of shareable truth.

Lina Ortega
Oct 22, 2023 · 10:22 PM

Counterpoint: sometimes effects are the simplest place to integrate an external system.

But even then, don't let the integration effect also manage UI posture. Keep the contract separate.

Evan Brooks
Nov 18, 2023 · 06:18 PM

The biggest mindset shift for our team was: if you can derive it, do it; if you can't, make the synchronization explicit and observable.

Once we adopted that, the number of "why did this run" bugs dropped a lot.

Anika Sharma
Dec 20, 2023 · 12:12 PM

We added a tiny tips log that prints when we commit state, and it made debugging much easier.

It also discouraged people from committing on every keystroke.

Salma Qureshi
Dec 31, 2023 · 11:23 PM

Takeaway: deleting effects is a symptom of better boundaries.

If your boundaries are clear (identity + lane + evidence), you don't need effects to patch consistency.