Hey everyone, we are trying to create a wrapper fo...
# javascript
f
Hey everyone, we are trying to create a wrapper for the
Prompt
component in React Router and we can't get it to work. This is the code we have:
Copy code
@file:JsModule("react-router-dom")
@file:JsNonModule
package react.router.dom

import react.Component
import react.RProps
import react.RState
import react.ReactElement

@JsName("Prompt")
internal external class Prompt : Component<PromptProps, RState> {
    override fun render(): ReactElement?
}

internal external interface PromptProps : RProps {

    var `when`: Boolean

    var message: String

}
This is the wrapper function we created:
Copy code
public fun RBuilder.prompt(show: Boolean, message: String): ReactElement {
    return child(Prompt::class) {
        attrs.`when` = show
        attrs.message = message
    }
}
And this is how we are calling it inside the
render()
of another component:
Copy code
prompt(show = true, message = "ERROR")
Anyone knows what we are doing wrong?
🤔 1
t
Copy code
val internal external Prompt: RClass<PromptProps>
?
f
@turansky I tried that but it still doesn't work. Would you be able to try it on your side and see if it works for you?
t
Could you check it with
commonjs
module type?
I see same declarations here
Modular declaration.cpp
f
Hey @turansky we have tried exactly the code you shared and it still doesn't work, we are guiding our definitions with how they are done in
kotlin-wrappers
as you suggested
Were you able to make this work for the Prompt?