Skip to the solution
EasyPhone Screen6 min read

What is React and its main features?

394 views

The problem

Question presented to candidate: "Start me off simply β€” what is React, and what are the main features that define it?"

What a strong answer should cover:

  • React is a library for building user interfaces, not a full framework β€” it deliberately leaves routing, data fetching, and build tooling to others.
  • Declarative: you describe what the UI should look like for a given state; React works out the DOM operations.
  • Component-based: the UI is composed from independent, reusable pieces that own their own state.
  • The Virtual DOM and reconciliation: React diffs a cheap in-memory description against the previous one and applies the minimum real DOM changes.
  • Unidirectional data flow: data travels down through props, which makes state changes traceable.
  • Learn once, write anywhere: the same component model targets DOM, native, and other renderers.
  • Bonus signal: an "element" is just a plain, frozen JavaScript object β€” the declarative description React works from.

Clarifying questions expected:

  • "Do you want the pitch, or the mechanism underneath it?"
  • "Should I cover the modern additions β€” Server Components and the compiler β€” or stick to fundamentals?"

Code / implementation expected: Optional. A tiny component showing declarative state-to-UI mapping is plenty.

  • react basics
  • library
  • declarative
  • virtual dom

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

6 min read Β· 8 sections

Try it in the playground

Open any example in the playground to run and change it.

ReactThe same UI declaratively β€” state in, UI out
import { useState } from "react";

// Declarative: this function says what the UI IS for a given state.
// It never says "find the counter node and change its text".
function Counter({ label }) {
  const [count, setCount] = useState(0);
  const status = count === 0 ? "untouched" : count > 5 ? "getting high" : "counting";

  return (
    <div style={{ border: "1px solid #ccc", borderRadius: 8, padding: 16, marginBottom: 12 }}>
      <strong>{label}</strong>
      <p style={{ margin: "8px 0" }}>
        Count: {count} β€” <em>{status}</em>
      </p>
      {/* Conditional UI is just an expression, not a DOM mutation */}
      {count > 5 && <p style={{ color: "crimson" }}>Above five!</p>}
      <button onClick={() => setCount((c) => c + 1)}>+1</button>{" "}
      <button onClick={() => setCount(0)}>reset</button>
    </div>
  );
}

export default function App() {
  // Component-based: the same component reused, each with its own state.
  const labels = ["First counter", "Second counter"];

  return (
    <div style={{ padding: 24, fontFamily: "system-ui" }}>
      {labels.map((l) => (
        <Counter key={l} label={l} />
      ))}
      <p style={{ color: "#666", fontSize: 13 }}>
        Each counter owns its own state. Nothing here queries or mutates the DOM β€”
        the UI is a pure function of state, and React applies the differences.
      </p>
    </div>
  );
}

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 18 of 119 in React.js

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

All React.js questions
Up nextEasy

How do you debug React applications?

Continue