From 2798c20f5a4705a0e37665143dc1e898d6831b3f Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Sun, 28 Oct 2018 09:46:14 +0000 Subject: [PATCH] Simplifying FileSize --- src/components/Options/FileSize.tsx | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/components/Options/FileSize.tsx b/src/components/Options/FileSize.tsx index d3432bdc..9355882a 100644 --- a/src/components/Options/FileSize.tsx +++ b/src/components/Options/FileSize.tsx @@ -7,32 +7,10 @@ interface Props { compareTo?: Blob; } -interface State { - sizeFormatted?: string; -} +interface State {} export default class FileSize extends Component { - constructor(props: Props) { - super(props); - if (props.blob) { - this.setState({ - sizeFormatted: prettyBytes(props.blob.size), - }); - } - } - - componentWillReceiveProps({ blob }: Props) { - if (blob) { - this.setState({ - sizeFormatted: prettyBytes(blob.size), - }); - } - } - - render( - { blob, compareTo }: Props, - { sizeFormatted }: State, - ) { + render({ blob, compareTo }: Props) { let comparison: JSX.Element | undefined; if (compareTo) { @@ -58,6 +36,6 @@ export default class FileSize extends Component { } } - return {sizeFormatted} {comparison}; + return {prettyBytes(blob.size)} {comparison}; } }