facebook / facebook/litho

[How to] Resize component externally

Open
#643 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
7.8k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.