Closed hou3172568 closed 2 months ago
Hey, it's hard to tell what may be wrong based on the small code sample that you shared. It would be helpful if you could create a small project that reproduces the issue so that we can take a look.
In other words, the best practices for using LithoView in RecyclerView on Android
Hello,
Ideally, you should try to use Litho APIs to emulate the list you want to render. Therefore, the recommendation would be to actually use a LazyList
.
If you have to integrate a LithoView
item in a RecyclerView
, it makes the solution more complex, because you have to manage the preparation (i.e, create it and set the root asynchronously, so that it can benefit from the background processing) of the ComponentTree
for each LithoView
, so that you have a performant implementation. This means, that you have to create a sliding window mechanism, and prepare the ComponentTree
ahead of time, so that whenever the RecyclerView
children are bound, you are able to just set the already prepared ComponentTree
into that LithoView
.
Thanks!
Version
Litho 0.47
Issues and Steps to Reproduce
When using LithoView as an Item in Android RecyclerView, when holder reuse and fast sliding causes update delays, causing the last view style to appear before updating to the new style; then i use setRootSync API, there is not smooth
Expected Behavior
the item update without delay
Link to Code
//this case is reuse if (tree != null && null != dataListenerWrapper) { //for async, update delays request()?.let { //let root component updateState dataListenerWrapper?.onReceive(it) } //for sync,not smooth tree?.setRootSync(MyComponent.create().build()) } }