0

When I add click event for the button it shows this error in ios simulatorこのエラーを解決するために、「RawTextは、明示的なテキストコンポーネントでラップする必要があり、」どのように反応し、ネイティブコンポーネント

renderLastSlide(index) { 
    if (index === this.props.data.length - 1) { 
    return (
     <Container> 
     <Content> 
      <Button rounded light> 
      <Text>Light</Text> 
      onPress={this.props.onComplete} 
      </Button> 
     </Content> 
     </Container> 
    ); 
    } 
} 

このエラーが発生し、このコードの問題は何ですか?

+0

あなたのインデントが悪いので、これを編集してください。修正後、自分でエラーが表示されます。 –

答えて

0

任意の要素にイベントを指定する必要があります。

<Button rounded light onPress={this.props.onComplete}> 
    <Text>Light</Text>  
</Button> 
0

あなたはボタンのうちたonPressパラメータを持っているので、その中にそれを置く:

は、ボタンの上にonPressを指定します。

renderLastSlide(index) { 
if (index === this.props.data.length - 1) { 
    return (
    <Container> 
     <Content> 
      <Button rounded light onPress={this.props.onComplete}> 
       <Text>Light</Text> 
      </Button> 
     </Content> 
    </Container> 
); 
} 
+0

ありがとうございました。ボタンイベントがクリックされても機能していない間は、エラーが表示されなくなりました。必要なすべてのスクリプトがscreenとapp.jsファイルに追加されているので、反応ナビゲーションではエラーと思われます。 –

0

ハイボタンの内側に置く必要があります。

renderLastSlide(index) { 
    if (index === this.props.data.length - 1) { 
    return (
     <Container> 
     <Content> 
      <Button 
      title= 'hai' 
      onPress={this.props.onComplete} // Add here 
      rounded 
      light 
      /> 
     </Content> 
     </Container> 
    ); 
    } 

Textコンポーネントを使用する場合は、ButtonよりTouchableOpacityを使用する方がよいと思います。タイトルにスタイルを追加することができます。

関連する問題