Open js/app.js
in your favorite code editor
Replace all var
definitions with let
Replace all React.createClass()
definitions with the new ECMAScript 6 class syntax. For example:
class Header extends React.Component {
};
Modify all class functions to use the ECMAScript 6 syntax for class function definitions. Use the render()
function below as an example:
class Header extends React.Component {
render() {
return (
<header>
<h1>{this.props.title}</h1>
</header>
)
}
};
In MortgageCalculator, replace getInitialState()
with a constructor implemented as follows:
constructor(props) {
super(props);
this.state = {
principal: this.props.principal,
years: this.props.years,
rate: this.props.rate
};
}
In the render()
function of the MortgageCalculator class, bind the call to the change event handlers as follows:
<input type="text" value={this.state.principal}
onChange={this.principalChange.bind(this)}/>
Replace all remaining function()
definitions with arrow functions
Use Object Destructuring syntax when appropriate
Build the app:
npm run webpack
Open index.html in your browser and test the application
The final code for this step is available in this branch.