how would i correctly write a kotlin wrapper for a...
# javascript
b
how would i correctly write a kotlin wrapper for a React component which resides in a sub path of a module? My approach does not work.
Copy code
@file:JsModule("@bootstrap-styled/provider/lib/BootstrapProvider")

package bootstrap

import react.*

@JsName("BootstrapProvider")
external class BootstrapProvider : Component<RProps, RState> {
    override fun render(): ReactElement?
}
just one example from muirwik, not my work.. just linked from my fork because it was easier and this one is ported to use the mpp plugin in gradle
b
this one worked for me, thank you!
Copy code
package bootstrap

import react.*

@JsModule("@bootstrap-styled/provider/lib/BootstrapProvider")
internal external val bootstrapProviderModule: dynamic

internal val BootstrapProvider: RClass<BootstrapProviderProps> = bootstrapProviderModule.default

interface BootstrapProviderProps : RProps {
    var reset: Boolean
    var injectGlobal: Boolean
}
❤️ 1
n
i am not sure making it internal will work for a library..
b
i made it because i've also created a builder
Copy code
fun RBuilder.bootstrapProvider(reset: Boolean = false, injectGlobal: Boolean = false, handler: RHandler<BootstrapProviderProps>) {
    BootstrapProvider {
        attrs {
            this.reset = reset
            this.injectGlobal = injectGlobal
            this.utils = BootstrapUtilsConfig()
        }

        handler()
    }
}