ghost-portal/packages/react-signer/src/Qr.tsx
Jaco Greeff 2b534fc1fb
Additional wrappers via React.memo (#2377)
* More React.memo

* Last non-memo functional components in staking
2020-03-12 15:45:59 +01:00

41 lines
1.1 KiB
TypeScript

// Copyright 2017-2020 @polkadot/react-signer authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BareProps } from '@polkadot/react-components/types';
import React from 'react';
import styled from 'styled-components';
import { QrDisplayPayload, QrScanSignature } from '@polkadot/react-qr';
interface Props extends BareProps {
address: string;
className?: string;
isScanning: boolean;
onSignature: (signature: { signature: string }) => void;
payload: Uint8Array;
}
const CMD_MORTAL = 2;
function Qr ({ address, className, isScanning, onSignature, payload }: Props): React.ReactElement<Props> {
return (
<div className={className}>
{
isScanning
? <QrScanSignature onScan={onSignature} />
: <QrDisplayPayload
address={address}
cmd={CMD_MORTAL}
payload={payload}
/>
}
</div>
);
}
export default React.memo(styled(Qr)`
margin: 0 auto;
max-width: 30rem;
`);