You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
brainpoint edited this page Mar 2, 2017
·
2 revisions
Example
使用TimerMgr来管理计时器有助于解决在页面切换时原计时器还存在而造成错误的情况
'use strict';importReact,{Component}from'react';import{AppRegistry,StyleSheet,}from'react-native';import{TimerMGr}from'react-componet'classextendsComponent{constructor(props){super(props);// new object.this.timerMgr=newTimerMgr();}componentWillUnmount(){// dispose obejct and cancel all timer.this.timerMgr.dispose();}doTimer(){// start timer.this.timerMgr.setTimeout((tm)=>{},2000);this.timerMgr.requestAnimationFrame((tm)=>{})}}
Method
构造
在组件的constructor函数中调用 this.timerMgr = new TimerMgr();