InterviewHubPRO
Section Overview
Q227

Question 227 of 445

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

51%
React & Modern Frontend (445 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

Should I learn ES6 before learning ReactJS?

No, you don’t have to learn es2015/es6 to learn react. But you may find many resources or React ecosystem uses ES6 extensively. Let's see some of the frequently used ES6 features,

  1. Destructuring: To get props and use them in a component
javascript
 // in es 5
 var someData = this.props.someData;
 var dispatch = this.props.dispatch;

 // in es6
 const { someData, dispatch } = this.props;
  1. Spread operator: Helps in passing props down into a component
javascript
 // in es 5
 <SomeComponent someData={this.props.someData} dispatch={this.props.dispatch} />

 // in es6
 <SomeComponent {...this.props} />
  1. Arrow functions: Makes compact syntax
javascript
 // es 5
 var users = usersList.map(function (user) {
   return <li>{user.name}</li>;
 });
 // es 6
 const users = usersList.map((user) => <li>{user.name}</li>);