facebook / facebook/litho

[How to] Resize component externally

Offen
#643 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Kotlin
Sterne
7.8k
Forks
768
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- [x] I have searched [existing issues](https://github.com/facebook/litho/issues) and this is not a duplicate

## Version
0.32

## Issues and Steps to Reproduce
So here is the use case that we're trying to resolve in my team.

We need to use a dynamically resized `WebView` that talks through our app with a `@JavascriptInterface` annotated methods. Basically when the content changes, it is recalculated and invokes a method `setHeight` and we're intercepting it. Then we change the `WebView` height and update the view.

After migrating to Litho we are not sure how can it be done. The `JavascriptInterface` object is passed as a prop to the `WebViewSpec` (`@MountSpec`). From there, I don't think there are any options to do the trick:
- dynamic props are a no-go, because we cannot update state from them (`@OnBindDynamicValue`) cannot have `ComponentContext` in it's parameters
- State can be updated only from other Litho components

So the only way I know of is recreating the components using different `@Props`, but there's no way to identify which Litho component actually called the method.

## Expected Behavior
We want to pass new properties from _outside_ to one of our components. Can this be done in any way?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.