how do you update state from a Android Fragment/View parent? like React's useImperativeHandle
- 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
***Add the version of the litho packages you use. You can paste the dependency
section of the gradle file if you have one.***
litho 0.39.0
kotlin 1.3.72
## Issues and Steps to Reproduce
***Replace this with steps to repro your issue.***
Assume I have component with state
```kotlin
class MyComponent() : KComponent() {
override fun DslScope.render(): Component{
val counter = useState { 0 }
return Text(
text = "Hello, World! $counter",
textSize = Sp(50f),
)
}
}
```
Then i used it in some fragment/view
```kotlin
val lithoView = LithoView.create(context /* context */, MyComponent())
mBinding.lithoContainer.addView(lithoView)
```
Then how do I update state/prop of MyComponent from parent?
Which is equivalent to React's useimperativehandle
https://reactjs.org/docs/hooks-reference.html#useimperativehandle
https://dev.to/collegewap/how-to-call-the-child-component-function-from-the-parent-component-in-react-3559
Contributor guide
Assessment
This issue has not been assessed yet.