UNPKG

crn-cli

Version:

The Ctrip React Native CLI Tools

1 lines 1.28 kB
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),h=r(d[6]),c=h.StyleSheet,p=h.Text,b=h.TouchableHighlight,f=h.View,x=(function(h){function c(n){var l;return t(this,c),(l=o(this,s(c).call(this,n))).state={status:'',loading:!1},l}return l(c,h),n(c,[{key:"loadTimeOutRequest",value:function(){var t=this;this.xhr&&this.xhr.abort();var n=this.xhr||new XMLHttpRequest;n.onerror=function(){},n.ontimeout=function(){t.setState({status:n.responseText,loading:!1})},n.onload=function(){},n.open('GET','https://httpbin.org/delay/5'),n.timeout=2e3,n.send(),this.xhr=n,this.setState({loading:!0})}},{key:"componentWillUnmount",value:function(){this.xhr&&this.xhr.abort()}},{key:"render",value:function(){var t=this.state.loading?u.createElement(f,{style:y.wrapper},u.createElement(f,{style:y.button},u.createElement(p,null,"Loading..."))):u.createElement(b,{style:y.wrapper,onPress:this.loadTimeOutRequest.bind(this)},u.createElement(f,{style:y.button},u.createElement(p,null,"Make Time Out Request")));return u.createElement(f,null,t,u.createElement(p,null,this.state.status))}}]),c})(u.Component),y=c.create({wrapper:{borderRadius:5,marginBottom:5},button:{backgroundColor:'#eeeeee',padding:8}});m.exports=x},666802,[3,4,5,8,9,11,15]);