crn-cli
Version:
The Ctrip React Native CLI Tools
1 lines • 2.07 kB
JavaScript
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),p=r(d[5]),u=r(d[6]),c=u.AppState,h=u.Text,y=u.View,S=(function(u){function S(){var n,l;t(this,S);for(var p=arguments.length,u=new Array(p),h=0;h<p;h++)u[h]=arguments[h];return(l=s(this,(n=o(S)).call.apply(n,[this].concat(u)))).state={appState:c.currentState,previousAppStates:[],memoryWarnings:0},l._handleMemoryWarning=function(){l.setState({memoryWarnings:l.state.memoryWarnings+1})},l._handleAppStateChange=function(t){var n=l.state.previousAppStates.slice();n.push(l.state.appState),l.setState({appState:t,previousAppStates:n})},l}return l(S,u),n(S,[{key:"componentDidMount",value:function(){c.addEventListener('change',this._handleAppStateChange),c.addEventListener('memoryWarning',this._handleMemoryWarning)}},{key:"componentWillUnmount",value:function(){c.removeEventListener('change',this._handleAppStateChange),c.removeEventListener('memoryWarning',this._handleMemoryWarning)}},{key:"render",value:function(){return this.props.showMemoryWarnings?p.createElement(y,null,p.createElement(h,null,this.state.memoryWarnings)):this.props.showCurrentOnly?p.createElement(y,null,p.createElement(h,null,this.state.appState)):p.createElement(y,null,p.createElement(h,null,JSON.stringify(this.state.previousAppStates)))}}]),S})(p.Component);e.title='AppState',e.description='app background status',e.examples=[{title:'AppState.currentState',description:'Can be null on app initialization',render:function(){return p.createElement(h,null,c.currentState)}},{title:'Subscribed AppState:',description:'This changes according to the current state, so you can only ever see it rendered as "active"',render:function(){return p.createElement(S,{showCurrentOnly:!0})}},{title:'Previous states:',render:function(){return p.createElement(S,{showCurrentOnly:!1})}},{platform:'ios',title:'Memory Warnings',description:'In the IOS simulator, hit Shift+Command+M to simulate a memory warning.',render:function(){return p.createElement(S,{showMemoryWarnings:!0})}}]},666763,[3,4,5,8,9,11,15]);