mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 17:49:52 +00:00
Simplifying FileSize
This commit is contained in:
@@ -7,32 +7,10 @@ interface Props {
|
||||
compareTo?: Blob;
|
||||
}
|
||||
|
||||
interface State {
|
||||
sizeFormatted?: string;
|
||||
}
|
||||
interface State {}
|
||||
|
||||
export default class FileSize extends Component<Props, State> {
|
||||
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<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
return <span>{sizeFormatted} {comparison}</span>;
|
||||
return <span>{prettyBytes(blob.size)} {comparison}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user