Recycle a list of litho components using a custom adapter

230 Views Asked by At

I am working on a project where I need recyling a list of litho components using a custom recyclerview adapter. The only issue is that I can't use RecyclerComponent which comes as part of the litho library.

Is there a way to do this? Specifically, what needs to go inside onCreateViewHolder() and onBindViewHolder()?

1

There are 1 best solutions below

0
On

You will want to use RecyclerCollectionComponent with the Sections API if possible: https://fblitho.com/docs/recycler-collection-component.

If you can't do that for some reason, you also have the option to use RecyclerBinder directly by adding components via insertItemAt/insertRangeAt. RecyclerBinder#getInternalAdapter will give you the RecyclerView.Adapter that you can give to your RecyclerView.