Skip to content
React·Intermediate·Output based·1 min read

How do you decide whether logic belongs in an event handler or an effect?

Short interview answer

If work happens because the user performed a specific action, keep it in that event flow. If it is required because the component is currently rendered with particular data and must synchronize an external system, use an effect.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to React hooks

Related questions