lbry-desktop/src/ui/component/common/qr-code.jsx

40 lines
817 B
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
2019-04-03 07:56:58 +02:00
import React, { Suspense } from 'react';
import classnames from 'classnames';
2018-03-26 23:32:43 +02:00
2019-05-07 23:38:29 +02:00
const LazyQRCodeElement = React.lazy(() =>
import(/* webpackChunkName: "qrCode" */
'qrcode.react')
);
2019-04-03 07:56:58 +02:00
2018-03-26 23:32:43 +02:00
type Props = {
value: string,
paddingRight?: boolean,
paddingTop?: boolean,
2018-03-26 23:32:43 +02:00
};
class QRCode extends React.Component<Props> {
static defaultProps = {
paddingRight: false,
paddingTop: false,
};
render() {
2018-06-13 17:43:04 +02:00
const { value, paddingRight, paddingTop } = this.props;
return (
<div
className={classnames('qr-code', {
'qr-code--right-padding': paddingRight,
'qr-code--top-padding': paddingTop,
})}
>
2019-05-07 23:38:29 +02:00
<Suspense fallback={<div />}>
2019-04-03 07:56:58 +02:00
<LazyQRCodeElement value={value} />
</Suspense>
</div>
);
}
}
2018-03-26 23:32:43 +02:00
export default QRCode;