小编Leo*_*eon的帖子

在react native中单击按钮时显示加载程序

我正在尝试在我的react native应用中实现加载器动画,但是单击动画后它不会触发加载器,尽管动画已经更改为true

在下面查看我的代码。

componentWillMount(){
    this.hideLoader();
}

showLoader = () => { this.setState({ showLoader:true }); };
hideLoader = () => { this.setState({ showLoader:false }); };

doSignup = () => {
    this.showLoader();
}

render() {
    console.log(this.state.showLoader);
    return (
        <View>
            <TouchableOpacity style={{ marginTop: 25 }} onPress={this.doSignup}>
              <View style={[ styles.button, { backgroundColor: '#5a0060' } ]}>
                <Text style={{ fontSize: 20, color: Colors.white }}>Sign Up Now</Text>
              </View>
            </TouchableOpacity>

            <View style={{ position: 'absolute', top: 0, bottom: 0, right: 0, left: 0 }}>
              <ActivityIndicator animating={this.state.showLoader} size="small" …
Run Code Online (Sandbox Code Playgroud)

javascript loader reactjs react-native

5
推荐指数
2
解决办法
5642
查看次数

标签 统计

javascript ×1

loader ×1

react-native ×1

reactjs ×1