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

    // in es 5
    var someData = this.props.someData;
    var dispatch = this.props.dispatch;
    // in es6
    const { someData, dispatch } = this.props;
  2. Spread operator: Helps in passing props down into a component

    // in es 5
    <SomeComponent someData={this.props.someData} dispatch={this.props.dispatch} />
    // in es6
    <SomeComponent {...this.props} />
  3. Arrow functions: Makes compact syntax

    // es 5
    var users = usersList.map(function (user) {
    return <li>{user.name}</li>;
    });
    // es 6
    const users = usersList.map((user) => <li>{user.name}</li>);

March 17, 2022
176