facebook / facebook/litho

[How to] Resize component externally

Abierto
#643 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Kotlin
Estrellas
7.8k
Forks
768
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

- [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?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.