Using getters for computed props/state
makeAndName () {
return `${this.props.make} ${this.props.name}`;
}
get brand () {
return `${this.props.make} ${this.props.name}`;
}
isAccelerating () {
return this.state.isRunning && this.state.pushingPedal;
}
get isAccelerating () {
return this.state.isRunning && this.state.pushingPedal;
}
render () {
return (
<div>
{this.props.brand}
{(this.state.running)
? <span>is running</span>
: null
}
</div>
);
}