From df1256a838ab1e1870339d6a90c0153cca6369d0 Mon Sep 17 00:00:00 2001 From: Luke Barton Date: Mon, 17 Oct 2016 23:17:33 +0100 Subject: [PATCH] Suggestions Stateless components (just a function, no life-cycle, pure) are a little faster. Unsure why you were doing the calculation of the position? --- app/components/Progress.jsx | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/app/components/Progress.jsx b/app/components/Progress.jsx index 3680940..e9d460b 100644 --- a/app/components/Progress.jsx +++ b/app/components/Progress.jsx @@ -1,31 +1,14 @@ 'use strict'; -import React, { Component } from 'react'; +import React from 'react'; -function workOutProgressValue(duration, currentTime) { - const difference = (duration - currentTime); - const remainingTime = (duration - difference); - const progressPercentage = (remainingTime / duration) * 100; - - return progressPercentage; -} - -class Progress extends Component { - render() { - const progress = workOutProgressValue(this.props.duration, this.props.currentTime); - - return (); - } -} - -Progress.defaultProps = { - max: 100 -}; +const Progress = (props) => ( + +) Progress.propTypes = { - duration: React.PropTypes.number, - currentTime: React.PropTypes.number, - max: React.PropTypes.number + duration: React.PropTypes.number.isRequired, + currentTime: React.PropTypes.number.isRequired }; export default Progress;