Why did we build React? – React Blog (2024)

This blog site has been archived. Go to react.dev/blog to see the recent posts.

There are a lot of JavaScript MVC frameworks out there. Why did we build Reactand why would you want to use it?

React isn’t an MVC framework.

React is a library for building composable user interfaces. It encouragesthe creation of reusable UI components which present data that changes overtime.

React doesn’t use templates.

Traditionally, web application UIs are built using templates or HTML directives.These templates dictate the full set of abstractions that you are allowed to useto build your UI.

React approaches building user interfaces differently by breaking them intocomponents. This means React uses a real, full featured programming languageto render views, which we see as an advantage over templates for a few reasons:

  • JavaScript is a flexible, powerful programming language with the abilityto build abstractions. This is incredibly important in large applications.
  • By unifying your markup with its corresponding view logic, React can actuallymake views easier to extend and maintain.
  • By baking an understanding of markup and content into JavaScript, there’sno manual string concatenation and therefore less surface area for XSSvulnerabilities.

We’ve also created JSX, an optional syntaxextension, in case you prefer the readability of HTML to raw JavaScript.

Reactive updates are dead simple.

React really shines when your data changes over time.

In a traditional JavaScript application, you need to look at what data changedand imperatively make changes to the DOM to keep it up-to-date. Even AngularJS,which provides a declarative interface via directives and data binding requiresa linking function to manually update DOM nodes.

React takes a different approach.

When your component is first initialized, the render method is called,generating a lightweight representation of your view. From that representation,a string of markup is produced, and injected into the document. When your datachanges, the render method is called again. In order to perform updates asefficiently as possible, we diff the return value from the previous call torender with the new one, and generate a minimal set of changes to be appliedto the DOM.

The data returned from render is neither a string nor a DOM node — it’s alightweight description of what the DOM should look like.

We call this process reconciliation. Check outthis jsFiddle to see an example ofreconciliation in action.

Because this re-render is so fast (around 1ms for TodoMVC), the developerdoesn’t need to explicitly specify data bindings. We’ve found this approachmakes it easier to build apps.

HTML is just the beginning.

Because React has its own lightweight representation of the document, we can dosome pretty cool things with it:

  • Facebook has dynamic charts that render to <canvas> instead of HTML.
  • Instagram is a “single page” web app built entirely with React andBackbone.Router. Designers regularly contribute React code with JSX.
  • We’ve built internal prototypes that run React apps in a web worker and useReact to drive native iOS views via an Objective-C bridge.
  • You can run Reacton the serverfor SEO, performance, code sharing and overall flexibility.
  • Events behave in a consistent, standards-compliant way in all browsers(including IE8) and automatically useevent delegation.

Head on over to https://reactjs.org to check out what we havebuilt. Our documentation is geared towards building apps with the framework,but if you are interested in the nuts and boltsget in touch with us!

Thanks for reading!

Why did we build React? – React Blog (2024)
Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 6178

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.