Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsafe childFunction #575

Merged
merged 1 commit into from
Jul 27, 2021

Conversation

sgrishchenko
Copy link
Collaborator

@sgrishchenko sgrishchenko commented Jul 27, 2021

Part of #358
cc @turansky @aerialist7

childFunction and RProps.children(value: T) signatures are removed because of unsafety.
These methods can lead to inconsistency and mistakes in codebase of kotlin-wrappers users.

Recommended solution for such cases:

interface RenderChildrenProps : RProps {
    var children: RBuilder.(value: Int) -> Unit
}

val RenderChildren = fc<RenderChildrenProps> { props ->
    div {
        props.children(this, 42)
    }
}

val Container = fc<RProps> {
    RenderChildren {
        attrs {
            children = { value ->
                span {
                    attrs {
                        jsStyle {
                            color = "red"
                        }
                    }

                    +"$value"
                }
            }
        }
    }
}

@Leonya Leonya changed the title childFunction is revomed childFunction is removed Jul 27, 2021
@sgrishchenko sgrishchenko changed the title childFunction is removed Remove unsafe childFunction Jul 27, 2021
@Leonya Leonya merged commit ea117a1 into JetBrains:master Jul 27, 2021
@Leonya
Copy link
Collaborator

Leonya commented Jul 30, 2021

Released in pre.223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants