Simplify the QR code component (#9828)

feature/default_network_editable
David Walsh 4 years ago committed by GitHub
parent e72f943951
commit 974ba4f691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      ui/app/components/ui/qr-code/qr-code.js

@ -9,15 +9,17 @@ import { checksumAddress } from '../../../helpers/utils/util'
export default connect(mapStateToProps)(QrCodeView)
function mapStateToProps(state) {
const { buyView, warning } = state.appState
return {
// Qr code is not fetched from state. 'message' and 'data' props are passed instead.
buyView: state.appState.buyView,
warning: state.appState.warning,
buyView,
warning,
}
}
function QrCodeView(props) {
const { message, data } = props.Qr
const { Qr, warning } = props
const { message, data } = Qr
const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(
data,
)}`
@ -29,7 +31,7 @@ function QrCodeView(props) {
<div className="qr-code">
{Array.isArray(message) ? (
<div className="qr-code__message-container">
{props.Qr.message.map((msg, index) => (
{message.map((msg, index) => (
<div className="qr_code__message" key={index}>
{msg}
</div>
@ -38,11 +40,7 @@ function QrCodeView(props) {
) : (
message && <div className="qr-code__header">{message}</div>
)}
{props.warning
? props.warning && (
<span className="qr_code__error">{props.warning}</span>
)
: null}
{warning && <span className="qr_code__error">{warning}</span>}
<div
className="qr-code__wrapper"
dangerouslySetInnerHTML={{

Loading…
Cancel
Save