RecyclerView in React Native: notifyItemInserted() and notifyDataSetChanged() have no effect

后端 未结 2 522
深忆病人
深忆病人 2021-01-15 12:52

I am experimenting with integrating a Firebase-backed RecyclerView in a React Native app. With hardcoded data it works well, but upon inserting rows loaded dynamically and c

2条回答
  •  旧时难觅i
    2021-01-15 13:39

    The root view in ReactNative is ReactRootView which onlayout is an empty method.

    when call notifyDatasetChanged in RecyclerView, it's actually request layout to relayout its children. And the layout method will call super.layout to travel the whole view tree first. So that't a problem when the root view is ReactRootView.

    You can manually call RecyclerView.onlayout(boolean changed, int l, int t, int r, int b) to trigger its children relayout to make notifyDatasetChanged work.

提交回复
热议问题