here 예제를 따라 사용자 정의 탐색 버튼을 작성했습니다. 그러나 사용자 지정 구성 요소를 사용할 때 onNavigatorEvent()
메서드가 더 이상 호출되지 않는 것처럼 보입니다. 나도 내 사용자 지정 구성 요소에 소품으로 onPress 이벤트를 통과했지만 그 undefined
통해 제공됩니다. 제가 누락 된 것이 있습니까? 당신이 전달하는 onPress에 방법, 그래서Wix React-Native-Navigation : 사용자 정의 구성 요소 버튼 용 onPress
Navigation.registerComponent('DoneButton',() => DoneButton);
const DoneButton = ({text, backgroundColor, textColor, onPressAction}) => {
var containerStyle = [{backgroundColor: backgroundColor, width: 70, height:30, justifyContent:'center', borderRadius:4, shadowColor:'black', shadowOpacity:0.2, shadowRadius:1, shadowOffset:{width:0, height:2}}];
return(
<TouchableOpacity style={containerStyle} onPress={onPressAction}>
<Text style={[{color:textColor, textAlign: 'center', fontSize:16}]}>
{text}
</Text>
</TouchableOpacity>
);
}
_renderDoneButton(){
this.props.navigator.setButtons({
rightButtons: [
{
id: 'Done'
component: 'DoneButton',
passProps: this._DoneButtonProps(),
}],
})
}
_DoneButtonProps(){
return {
text: 'Done',
backgroundColor: 'green',
textColor: 'white',
onPressAction: this._doneAction.bind(this)
}
}
_doneAction(){
alert('Done');
}
안녕하세요, 일부 코드를 공유 할 수 있습니까? 등록,'function' 그 자체 – gran33
@ gran33 좋아요, 더 많은 코드를 추가하십시오 – pnizzle
@ gran33 새로 고침하고 업데이트 된 코드를보세요 – pnizzle