Skip to content

Kotlin 1.5.30 - Breaking Change

Latest
Compare
Choose a tag to compare
@cfnz cfnz released this 25 Aug 10:17
· 30 commits to master since this release

This release moves to Kotlin 1.5.30 and version 17.0.2-pre.236-kotlin-1.5.30 of the react wrappers.

The prior version used pre.204 version of the wrappers. Sometime after pre.204 the Kotlin wrappers have undergone quite a few changes to clean up the APIs. One of the changes was to not return a React Element when adding a child. This may break some code.

The key piece of advice is not to return React Element from any of your components but rather return nothing (i.e. Unit). For example, previously

class App : RComponent<RProps, RState>() {
    ...
}

fun RBuilder.app() = child(App::class) {}

Now you would have:

class App : RComponent<Props, State>() {
    ...
}

fun RBuilder.app() {
    child(App::class) {}
}

In places where you need a component returned such as passing it as a param or setting a prop, you can wrap the component in a buildElement {} function. Previously you might have used addChild = false on the createStyled function as was used in the test app.

These changes can be observed by comparing pretty much any of the test app classes as they pretty much all changed.