React is a JavaScript library created by Facebook for building user interfaces. It helps developers create reusable UI components for web applications.
How does React Work?
React doesn’t immediately update the whole web page. Instead, it makes a copy of the page in memory. React then figures out the quickest way to update just the parts of the page that changed, making the process faster and smoother.
How to use ES6?
Working: You write your ‘.js‘ files in the development environment and can use whatever ES6 syntax that you want. Rather than loading them directly, you set up a web-pack to load js files with Babel.
React Without ES6:
Normally you would define a React component as a plain JavaScript class:
If you don’t use ES6 yet, you may use the create-react-class
module instead-
Declaring Default Props:
functions and ES6 classes defaultProps
is defined as a property on the component itself:
With createReactClass()
, you need to define getDefaultProps()
as a function on the passed object: