2017-09-06 4 views
0

ListHeaderComponentを使用して、React-Nativeでは、ListHeaderComponentのshouldComponenupdate関数は(実行されていても)無視されます。 shouldComponentUpdateにfalseを返しても、私のコンポーネントは常に元に戻ります。 ListHeaderComponentを再レンダリングしないようにするにはどうすればよいですか? FlatList前に置くReact-Native FlatList ListHeaderComponentはshouldComponentUpdateを無視します

<Card> 
    <FlatList data={comments} 
       ListHeaderComponent={() => <PostHeader navigation={this.props.navigation} post={this.props.post} />} 
       style={{flex:1}} 
       onRefresh={() => this.props.getPost(mediaId, 'newsfeed', true)} 
       refreshing={isRefreshing} 
       keyExtractor={(comment) => comment.id} 
       removeClippedSubviews={false} 
       renderItem={(comment) => <Comment comment={comment.item} /> } /> 

    <PostComment newComment={newComment} 
       postComment={() => this.props.postComment(newComment.content, mediaId, profile.id)} 
       reset={()=> this.props.resetNewComment} 
       onTextChange={this.props.newCommentTextChanged} /> 
    {Platform.OS.toLocaleLowerCase() === 'ios' && 
    <KeyboardSpacer /> 
    } 
    </Card> 

は、望ましくない動作を停止しますが、これはFlatListを使用しているとき、私はむしろ避けたScrollViewに多くのことを包む必要となります。

+0

どのコンポーネントでは? – bennygenel

+0

申し訳ありませんが、質問が更新されます。 PostHeaderコンポーネントで – Dogla305

+0

問題は、Thogh PostHeaderコンポーネントでも親コンポーネントが再レンダリングしないということです。この平均PostHeaderも再レンダリングされます。 – bennygenel

答えて

関連する問題