Monitor android phone returns React physical components / rollback / back key events

When the end of the current page to run embedded webview sometimes need to listen to the phone's physical return key event to do some custom operations.

For example, I recently encountered a page in which the batch has selected function when you click on the phone's Back button, clear the check status on the page. I take the following measures:

ResetChoose callback is executed when you click back button, the constructor React to mount components inside the window object below, pay attention to where you want to bind this, so you can use the callback method resetChoose inside this.setState

To register

 

Author: Zhang Xuefei
Source: https://zhangxuefei.site/p/2572
Copyright: welcome to reprint, but must indicate the source and give the original connection in the apparent position of the article page, otherwise reserved the right to pursue legal responsibilities.

Guess you like

Origin www.cnblogs.com/mszhangxuefei/p/10953914.html