<https://github.com/JetBrains/kotlin-wrappers/pull...
# react
c
https://github.com/JetBrains/kotlin-wrappers/pull/564 looks like it might break a few things which is fine if there is good reason. Is there a place where such changes are described? For example, is this to make things more "React like"? I could not find an issue discussing it or anything describing the why.
t
For example, is this to make things more “React like”?
Compose-like (JSX-like?)
I could not find an issue discussing it or anything describing the why.
Main problems described here Return type removed as cleanup result Cleanup in progress 🙂
What is your use case?
c
Thanks for the reference, I had read that before but didn't make the link with the child functions. My use case is the Muirwik components, pretty much all of which (close to 100 of them) currently return a ReactElement via RBuilder.child(...).
Most of the components actually call a helper function, createStyled, where you can choose to add the created component as a child or not... I guess I could modify that helper and most of the library will be unchanged... Just need to decide if that will be the way to go as it will be then not following the newer convention...
I guess there might be quite a bit of code out there that will need changing (if I understand correctly). For example, the readme still has:
Because this can be quite cumbersome to write, you can define an 
RBuilder
 extension function to make the call site a bit cleaner, allowing you to write 
welcome("Kotlin")
 instead:
Copy code
fun RBuilder.welcome(name: String) = child(welcome) {
    attrs.name = name
}
It seems that all these RBuilder extension functions may need to be tweaked, which might mean that most peoples components may have to be tweaked... though I guess now child returns Unit, so as long as the code calling it does not assume a ReactElement is returned, it might still be OK. Lots (well, some of the stuff I have looked at :-)) of my client code however assumes a ReactElement is returned.
t
child
- redundant in your case
Now:
Copy code
fun RBuilder.welcome(name: String) { 
    welcome {
       attrs.name = name
    }
}
Future:
Copy code
fun RBuilder.welcome(name: String) { 
    welcome {
       // no attrs 
       this.name = name
    }
}