2017-09-19 15 views
1

:TouchableOpacity의 onPress 이벤트를 트리거하는 방법은 무엇입니까? HTML에서 jQuery를 사용

$("input:button").on("click",function(){alert(1)}).click() 

그것은 이벤트를 클릭 트리거 할 수 있습니다.

과 비슷한 일을하고 싶습니다. react-nativeTouchableOpacity의 이벤트가 있습니다.

<TouchableOpacity activeOpacity={0.75} key={id} onPress={() => {onChangeAttribute(key)}}> 
    {<Text>{value.name}</Text>} 
</TouchableOpacity> 

어떻게 해야할지 모르겠다. 나는 그것을 찾았지만 아무 것도 발견하지 못했다. 사용자의 두드리기가 아닌 코드에서 onPress 이벤트를 트리거하기 만하면됩니다.

미리 감사드립니다.

+0

? 구문은 정확합니다. –

+0

onPress = {() => {this.methodname()}} –

+0

코드에서이 onPress 이벤트를 실제로 호출하는 대신 jQuery의 click() 메서드와 같이 호출하려고합니다. – lison

답변

0

당신은해야이 같은 코드 : 당신이 작동하지 않는 시도 무엇

render() { 
    <TouchableOpacity activeOpacity={0.75} key={id} onPress={onChangeAttribute(key)}> 
    {<Text>{value.name}</Text>} 
    </TouchableOpacity> 
} 
+0

사용자 터치없이 onveress eveent를 트리거 하시겠습니까? –

+0

아직 없습니다. render()에서 setState()를 제거하기가 약간 어렵습니다. 화살표 기능을 삭제하기 전에 제대로 작동했습니다. 그래서 제안을 포기할 것입니다 ... – lison