CodePark/ questions / Fundamentals & JSX
START PRACTICINGPRACTICE
Frontend question · React › Fundamentals & JSX

What is React, and why would a team choose it?

React is a JavaScript library for building user interfaces out of components. A component is a function that takes props, its inputs, and returns a description of the UI.

You write declarative code. This means you describe what the UI should look like for the current state. React then works out the DOM changes needed to get there. For example, you write {isOpen && <Menu />}, and React adds or removes the menu for you.

Teams choose React for these reasons:

  • Components are reusable and composable: you build big pieces out of small ones.
  • Data flows one way, from parent to child through props. This makes behaviour easier to follow.
  • The ecosystem is large: routing, data fetching, testing tools and frameworks such as Next.js.

React itself only handles the view layer. A separate renderer draws the output. react-dom renders to the browser DOM, and React Native renders to native mobile apps.

  • React is a library for building UIs from components, not a full framework.
  • React is declarative: you describe the UI for the current state, and React updates the DOM.
  • Data flows one way, from parent to child through props.
  • Components are reusable and composable, and the ecosystem is large.
  • The core does not depend on one platform: react-dom renders to the browser and React Native to mobile apps.