2

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'); 
} 
+0

안녕하세요, 일부 코드를 공유 할 수 있습니까? 등록,'function' 그 자체 – gran33

+1

@ gran33 좋아요, 더 많은 코드를 추가하십시오 – pnizzle

+0

@ gran33 새로 고침하고 업데이트 된 코드를보세요 – pnizzle

답변

2

버전 1.1.282 때문에 사용자 정의 버튼에 unserializable 소품을 전달할 수 있습니다

이 내가 버튼을 만드는 것 함수에 onPress에 소품을 전달하고 어떻게 작동해야합니다.

+0

소품이 잘 전달됩니다. onPress를 제외하고. 모든 소품을 디버깅 할 때 유효하지만 onPressAction은 정의되지 않았습니다. 가능하다면 실천 사례를 제공해 줄 수 있습니까? – pnizzle

+1

어떤 RNN 버전을 보유하고 있습니까? –

+0

버전 1.1.262가 있습니다. 그리고 소품은 당신이 말한대로 전달되고 있습니다. onPress 소품을 특별히 언급하지 않는 한. 그렇다면 업그레이드하고 다시 테스트 할 것입니다. – pnizzle