import React from 'react'; import translate from 'translations'; import { stripHexPrefix } from 'libs/formatters'; import { PaperWallet } from 'components'; interface Props { address: string; privateKey: string; } interface State { paperWalletImage: string; } export default class PrintableWallet extends React.Component { public state: State = { paperWalletImage: '' }; private paperWallet: PaperWallet | null; public componentDidMount() { setTimeout(() => { if (!this.paperWallet) { return this.componentDidMount(); } this.paperWallet.toPNG().then(png => this.setState({ paperWalletImage: png })); }, 500); } public render() { const { address, privateKey } = this.props; const { paperWalletImage } = this.state; const pkey = stripHexPrefix(privateKey); const disabled = paperWalletImage ? '' : 'disabled'; return (
(this.paperWallet = c)} /> {translate('X_SAVE_PAPER')}
); } }