Visible Event hasn't triggered when fragment resumed.
I also tried to call LithoView.setVisibilityHint(true);
on fragment resume but it doesn't work to trigger the visible event of the Component.
However, it will be triggered successfully when scrolling up / down to show the component view in the RecyclerCollectionComponent.
Asked
Active
Viewed 284 times
0

Kit
- 2,370
- 13
- 11
1 Answers
1
This is unfortunately a known problem right now. If you call LithoView#setVisibilityHint(true)
on resume, you will have also needed to call LithoView.setVisibilityHint(false)
in pause: in that case, you should get invisibility and visibility callbacks when you pause and resume, respectively.

Foxichu
- 952
- 10
- 22
-
Thanks for your reply. Actually, I want to have more flexibility to update the state of litho components inside recyclercollectioncomponent in the fragment or activity. Do you have good practices to do so? – Kit Jan 06 '19 at 07:23
-
The recommended way would be to do this via props if at all possible as it will help achieve a simpler one-way data flow. If that's not possible, you can set a listener within the component if necessary from `onCreateInitialState`. There's currently not a good reciprocal lifecycle method to `onCreateInitialState` (i.e. an `onDestroy`), so keep that in mind -- hopefully one will be added soon :) – Foxichu Jan 08 '19 at 17:53
-
I think adding a listener as prop to component is not a good practice. Actually, I asked the contributors for this question but no response. Thanks for your help. Foxichu – Kit Jan 11 '19 at 01:36
-
I did not mean adding a listener as a prop, they are two different suggestions :) : 1. Whenever you want to update state based on external events (e.g. from Fragments or Activitys), try to structure as a prop change instead and call setRootAsync. This is the best choice for now if it's possible. 2. Alternately, if this is not possible for some reason, you can set a listener from inside the component, but there are the lifecycle issues I mentioned above – Foxichu Jan 11 '19 at 16:09