Good news! We’ve updated our Learn ReactJS: Part I and Learn ReactJS: Part II courses to use JavaScript ES6. ES6 (the sixth version of ECMAScript, which is the specification JavaScript is based on) introduces new syntax and additional functionality that makes the popular web language even more powerful than before.
Why? Since its release, JavaScript ES6 syntax has quickly become best practice and we believe it is important for anyone learning to code to get the most up-to-date education for what’s relevant in the industry today. Additionally, Facebook (creators of ReactJS) will be deprecating pre-ES6 syntax, which makes it even more important for everyone to learn ES6.
How does this impact you? If you’ve started any of our ReactJS courses, some of the code you wrote may now be invalid under the new syntax. Therefore, if you revisit any of the exercises that got updated, you’ll see the exercise code will have reset to show the new syntax. You can still navigate the course, but you’ll have to redo some exercises if you want to be able to run the code again.
If you don’t want to go back through the course to learn about the new syntax, we’ve outlined all the changes introduced below:
Syntax Changes to Learn ReactJS Courses
Learn ReactJS: Part I, JSX
- Change
var
tolet
orconst
:
- Change
var React = require('react');
toimport React from 'react';
:
- Change
var ReactDOM = require('react-dom')
; toimport ReactDOM from 'react-dom';
Learn ReactJS: Part I, React Components
- Change class methods’ syntax to method shorthand, for instance:
Learn ReactJS: Part I, Components Interacting
- Use
export
andexport default
to export each component instead ofmodule.exports
, for example:
- Change local file require statements to import statements, for example:
getDefaultProps()
should be replaced with staticdefaultProps
object property, for example:
- Replace
getInitialState()
with callingsuper()
and settingstate
inconstructor()
, for example:
- Bind methods in
constructor
to replace auto-binding:
Learn ReactJS: Part II, Advanced React (PropTypes)
propTypes
instance property should be replaced with static property, for example: