File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,15 +110,24 @@ class InputArea extends React.Component {
110110
111111 render ( ) {
112112 const {
113- classes,
114- autoFocus,
115- height,
113+ value,
116114 width,
115+ height,
116+ classes,
117117 onChange,
118+ autoFocus,
118119 placeholder,
119120 showQrScanner,
120121 } = this . props ;
121122
123+ if ( this . state . value !== value ) {
124+ this . previousValueProp = value ;
125+
126+ this . setState ( {
127+ value : value ,
128+ } ) ;
129+ }
130+
122131 return (
123132 < div className = { classes . formGroup } >
124133 < ReactNotification ref = { this . notificationDom } />
@@ -172,6 +181,7 @@ InputArea.propTypes = {
172181 width : PropTypes . number . isRequired ,
173182 onChange : PropTypes . func . isRequired ,
174183 error : PropTypes . bool . isRequired ,
184+ value : PropTypes . string ,
175185 autoFocus : PropTypes . bool ,
176186 placeholder : PropTypes . string ,
177187 showQrScanner : PropTypes . bool ,
Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ import Qrious from 'qrious';
33import PropTypes from 'prop-types' ;
44
55class QrCode extends React . Component {
6- render ( ) {
7- const { size, link } = this . props ;
8-
9- if ( link ) {
10- this . id = `qr-${ link . substring ( 0 , 4 ) } ` ;
6+ id = '' ;
117
8+ drawQrCode = ( ) => {
9+ if ( this . id !== '' ) {
10+ const { size, link } = this . props ;
1211 const element = document . getElementById ( this . id ) ;
12+
1313 this . qr = new Qrious ( {
1414 element,
1515 } ) ;
@@ -24,8 +24,26 @@ class QrCode extends React.Component {
2424 foregroundAlpha : 1 ,
2525 } ) ;
2626 }
27+ } ;
28+
29+ componentDidUpdate ( ) {
30+ this . drawQrCode ( ) ;
31+ }
2732
28- return < canvas id = { this . id } /> ;
33+ componentDidMount ( ) {
34+ this . drawQrCode ( ) ;
35+ }
36+
37+ render ( ) {
38+ const { link } = this . props ;
39+
40+ if ( link ) {
41+ this . id = `qr-${ link . substring ( 0 , 4 ) } ` ;
42+
43+ return < canvas id = { this . id } /> ;
44+ } else {
45+ return < div /> ;
46+ }
2947 }
3048}
3149
Original file line number Diff line number Diff line change @@ -81,17 +81,21 @@ class PayInvoice extends React.Component {
8181
8282 return (
8383 < View className = { classes . wrapper } >
84- < View className = { classes . qrcode } >
85- < DetectResize >
86- { width =>
87- width <= 375 ? (
88- < QrCode size = { 200 } link = { swapResponse . invoice } />
89- ) : (
90- < QrCode size = { 300 } link = { swapResponse . invoice } />
91- )
92- }
93- </ DetectResize >
94- </ View >
84+ { window . innerWidth < 768 ? (
85+ < div />
86+ ) : (
87+ < View className = { classes . qrcode } >
88+ < DetectResize >
89+ { width =>
90+ width <= 375 ? (
91+ < QrCode size = { 200 } link = { swapResponse . invoice } />
92+ ) : (
93+ < QrCode size = { 300 } link = { swapResponse . invoice } />
94+ )
95+ }
96+ </ DetectResize >
97+ </ View >
98+ ) }
9599 < View className = { classes . info } >
96100 < p className = { classes . title } >
97101 Pay this { swapInfo . base } Lightning invoice:
You can’t perform that action at this time.
0 commit comments