Hi everyone, I'm trying to create a Kotlin wrapper...
# javascript
f
Hi everyone, I'm trying to create a Kotlin wrapper for the react-gtm library (https://github.com/alinemorelli/react-gtm/blob/master/src/TagManager.js) and I can't seem to make it work. This is what I have so far:
Copy code
@file:JsModule("react-gtm-module")
@file:Suppress("unused")
package react.gtm

external object TagManager {

    fun initialize(args: TagManagerArgs)

}
but when I run it I get the error
Uncaught TypeError: Cannot read property 'initialize' of undefined
. Any idea what I'm doing wrong?
After trying a few things this worked out:
Copy code
@JsModule("react-gtm-module")
@JsNonModule
external object TagManager {

    fun initialize(args: TagManagerArgs)

}
It seems that I have to do it like this because of how the module is exported on the JS library. Hopefully it helps someone.
👍 1