Babel transpilation code example
Example 1: transpiler Babel
export default React.createClass({
getInitialState() {
return { num: this.getRandomNumber() };
},
getRandomNumber() {
return Math.ceil(Math.random() * 6);
},
render() {
return <div>
Your dice roll:
{this.state.num}
</div>;
}
});
Copy
Example 2: transpiler Babel
npm install --save-dev @babel/preset-react
Copy