Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 3.63 KB

File metadata and controls

65 lines (42 loc) · 3.63 KB

React

What is React?

React is a declarative, efficient, and flexible JavaScript library for building Single Page Application(SPA). It allows you to create front-end applications through the creation of reusable, decoupled and testable components.

What can I build with React?

To get some ideas of what you can build with React, check out:

What's the benefit of using React?

React allows you to build interactive/dynamic UI in declarative style.

Demo: Simple page (without React vs with React)

Problems with direct DOM manipulation with JavaScript:

  1. Imperative. We have to specify line by line what the HTML should look like, and our javascript code is tightly coupled to the HTML layout (e.g. i need to get the second paragraph to do xyz)
  2. The tight coupling leads to unexpected breaking changes. If somebody adds a paragraph to the top of the html page, our javascript code with break
  3. Imperative style is awkward and verbose. we have to reach inside the DOM, get the node, change the node in javascript, and then stick it back in the DOM.
  4. Not unit-testable
  5. Difficult to modularize. As this app grows, the javascript/HTML file is likely to grow longer and longer.

Benefits with React approach in this demo:

  1. Declarative. We declare (using JSX) what the HTML should look like and React makes it so!
  2. Only 1 line of HTML!
  3. Ability to use javascript logic makes code less verbose
  4. Easy to unit-test
  5. Easy to modularize
  6. Easy to read ==> Easy to scale and maintain

How to learn React?

When working with React, you will undoubtedly face new and scary jargon. An important way to learn and be effective with React is to:

  • Understand its building blocks (e.g. JSX, components, props, state, etc)
  • Build on what you have learnt about JavaScript (functions, classes, ES6 syntax, static methods, modules, etc.). Make sure you know those JavaScript fundamental.
  • Build applications with React.

To start with, you can follow this official React Getting Started Guide (Recommendation: Work through tutorial up through till 'Thinking in React')

Online Courses

Online Editors

Resources