异步React Native的按钮不响应问题

时间:2019-02-27 09:38:10

标签: android ios react-native expo

我从github项目复制了休闲代码,并尝试使用expo。该项目执行没有错误,但当我按下按钮时,没有任何反应。甚至没有错误,这是我的代码 注意:我在onChooseImagePress中添加了一个警报,警报工作正常

ofs << " more lorem ipsum";

2 个答案:

答案 0 :(得分:0)

代码中存在多个语法问题:

  1. const样式... 应该在当前在类外部悬挂的render函数中定义
  2. 支架不匹配
        return (
            <View style={styles.container}>
            <Button title="Choose image..." onPress={this.onChooseImagePress} />
            </View>
            );
        }
    } // the class ends here


Please let me know if it still doesn't work

答案 1 :(得分:0)

尝试使用以下代码

constructor() {
    super();
    this.state = { }; 
    this.onChooseImagePress= this.onChooseImagePress.bind(this);

  } 

<Button title="Choose image..." onPress={() => this.onChooseImagePress()} /> 
相关问题