ES6 and React Elements
ES6 (ECMAScript 2015)
ES6 is the second major revision to JavaScript.
It is a scripting language specification standardized by ECMAScript International.
It is used by applications to enable client-side scripting.
The specification is influenced by programming languages like Self, Perl, Python, Java, etc.
Languages like JavaScript, Jscript and ActionScript are governed by this specification.
React DOM Render
The method ReactDom.render()
is used to render (display) HTML elements.
React Elements
React applications are usually built around a single HTML element.
React developers often call this the root node (root element):
React elements look like this:
const element = <h3>Hello React!</h3>;
|
Elements are rendered (displayed) with the
ReactDOM.render( )
method:
ReactDOM.render( element, document.getElementById( 'root' ) );
|
React elements are immutable; i.e., they cannot be changed.
The only way to change a React element is to render a new element every time.
The following script uses the function
setInterval()
, which is used to invoke a function or a piece of code repeatedly after a specific amount of time.