2017-06-16 31 views
1

このドキュメント(https://facebook.github.io/react-native/docs/gesture-responder-system.html)では、タッチイベントは子供に渡され、親が消費します。子供がイベントに反応しない場合、私は直面します他のTouchableOpacity内にネストされたTouchableOpacityがタッチで適切に反応しないという問題があります。別のTouchableOpacityの中のStacked TouchableOpacityはクリック可能ではありません

<ScrollView> 
    <TouchableOpacity onPress={() => console.log('This is printed always')}> 
    <View> 
     <Text>I can click here</Text> 
     <TouchableOpacity onPress={() => console.log('This is printed never')}> 
     <Text>I can click here but the outer onPress is called instead of the inner one</text> 
     </TouchableOpacity> 
    </View> 
    </TouchableOpacity> 
</ScrollView> 

同じことがTouchableOpacitys内部のボタンのために起こる次のように私の構造は次のとおりです。ボタンをクリックすると、親TouchableOpacityのたonPressメソッドを呼び出します

は、私が何かを監督午前?

答えて

1

TouchableOpacityWithoutFeedbackを使用すると、TouchableOpacityをラップすることができます。

のような何か:

<TouchableOpacity onPress={() => console.log('This is printed always')}> 
    <View> 
     <Text>I can click here</Text> 
     <TouchableWithoutFeedback> 
      <TouchableOpacity onPress={() => console.log('This is printed never')}> 
       <Text>I can click here but the outer onPress is called instead of the inner one</text> 
      </TouchableOpacity> 
     </TouchableWithoutFeedback> 
    </View> 
</TouchableOpacity> 
関連する問題