Browse Source

FIX: Error in back button - Marketplace #922

disable-batching-for-eps
marcosrdz 5 years ago
committed by Overtorment
parent
commit
c0d2157d9c
  1. 14
      screen/wallets/marketplace.js

14
screen/wallets/marketplace.js

@ -11,6 +11,8 @@ export default class Marketplace extends Component {
headerLeft: null, headerLeft: null,
}); });
webview = React.createRef();
constructor(props) { constructor(props) {
super(props); super(props);
if (!props.navigation.getParam('fromWallet')) throw new Error('Invalid param'); if (!props.navigation.getParam('fromWallet')) throw new Error('Invalid param');
@ -21,7 +23,7 @@ export default class Marketplace extends Component {
fromWallet, fromWallet,
canGoBack: false, canGoBack: false,
}; };
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton.bind(this)); BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
} }
async componentDidMount() { async componentDidMount() {
@ -32,7 +34,7 @@ export default class Marketplace extends Component {
address = this.state.fromWallet.getAddress(); address = this.state.fromWallet.getAddress();
} }
let url = 'https://bluewallet.io/marketplace-btc/?address=' + address; // default const url = 'https://bluewallet.io/marketplace-btc/?address=' + address; // default
this.setState({ this.setState({
url, url,
@ -40,11 +42,11 @@ export default class Marketplace extends Component {
} }
componentWillUnmount = () => { componentWillUnmount = () => {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton.bind(this)); BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
}; };
handleBackButton() { handleBackButton = () => {
this.state.canGoBack ? this.webview.goBack() : this.props.navigation.goBack(null); this.state.canGoBack ? this.webview.current.goBack() : this.props.navigation.goBack(null);
return true; return true;
} }
@ -59,7 +61,7 @@ export default class Marketplace extends Component {
return ( return (
<WebView <WebView
ref={ref => (this.webview = ref)} ref={this.webview}
onNavigationStateChange={this._onNavigationStateChange} onNavigationStateChange={this._onNavigationStateChange}
source={{ source={{
uri: this.state.url, uri: this.state.url,

Loading…
Cancel
Save