Skip to content
tezvyn:

Compare multiple boolean props versus a single status string prop

Source: kyleshevlin.comMediumHow cards are made

Compare multiple boolean props versus a single status string prop
Tests

preventing impossible UI states.

Key points

Booleans let callers pass conflicting flags like isLoading plus isError, leaking implementation priority; a single status enum makes invalid states unrepresentable.

Watch out for

claiming booleans are simpler.

What's really being asked

This question tests whether you can recognize API design patterns that create impossible states and whether you prefer making invalid states unrepresentable over defensive coding inside the component. It surfaces your opinions on type safety, prop surface area, and how much you trust consumers of your component.

The full answer

A strong answer hits four points in order. First, multiple boolean props such as isLoading and isError allow the consumer to pass conflicting flags at the same time, which creates impossible UI states. Second, when conflicts occur, the component must silently prioritize one flag over another through the order of conditional checks, which leaks implementation details. Third, a single string prop such as status with an enumerated set of values makes impossible states literally unrepresentable, so the compiler or runtime can reject or gracefully handle garbage input. Fourth, a single enum prop is easier to extend later because adding a new state means adding one string value rather than a new boolean prop and new conditional branches across the codebase.

The mistakes people make

The biggest red flag is claiming that booleans are simpler or more flexible. Another warning sign is saying that consumers should just read the docs and avoid passing conflicting props. Interviewers also frown on answers that ignore type safety or argue that runtime prop-type warnings are enough defense. Suggesting an ESLint rule to ban combinations is creative but misses the point that the API itself should prevent the error.

What usually comes next

The interviewer might ask how you would handle a component that truly has orthogonal concerns, such as a disabled state that can apply to any status. They may also ask how you would model this in TypeScript, or how you would migrate a legacy component from multiple booleans to a single enum without breaking existing consumers.

A concrete example

Imagine a CommonButton with primary, warning, and danger booleans. If a consumer writes primary warning danger, the rendered color depends on the order of if statements inside the component, exposing internal priority logic. Replacing those three flags with a single variant enum of default, primary, warning, and danger removes the conflict entirely. An invalid variant string can fall back to the default color, and adding a new style later only requires updating the enum map rather than adding another boolean and another conditional.

Interview question

Which problem arises when a component exposes multiple boolean props such as isLoading and isError?

  • a.It allows conflicting flags that create impossible states and leaks internal priority logic.Correct
  • b.It requires runtime prop-type checks or ESLint rules to catch invalid prop combinations.
  • c.It prevents consumers from combining orthogonal states, making the API less flexible than booleans.
  • d.It increases prop surface area, making the component harder to document and maintain over time.
Why?

Multiple booleans let callers pass conflicting flags like isLoading and isError, which creates impossible states and forces silent prioritization via conditional ordering. The argument that booleans are simpler or more flexible is a red flag because it makes invalid states representable rather than unrepresentable.

Just read this? Test yourself on what you have been reading.

Read the original → kyleshevlin.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on api design — each one lists the topics its interview covers.

See open roles