Hi all! I'm trying to add `react-tooltip` to my p...
# javascript
j
Hi all! I'm trying to add
react-tooltip
to my project. https://www.npmjs.com/package/react-tooltip It has some static methods like
ReactTooltip.show(element)
How can I add these methods with the new IR compiler? I used a workaround to avoid problems with
default
described here: https://github.com/anton-bannykh/web-app-react-kotlin-js-gradle/blob/IR-fixes/src/main/kotlin/ReactPlayer.kt This thread is related: https://github.com/JetBrains/kotlin-wrappers/issues/361 And this is my code for ReactTooltip:
Copy code
import react.RClass
import react.RProps

@JsModule("react-tooltip")
@JsNonModule
external object ReactTooltip {
    val default: RClass<ReactTooltipProps>
}

external interface ReactTooltipProps : RProps {
    var id: String
    var type: String
}
I tried to add this method as an instance method on
object ReactTooltip
, but JS says it's not a function. I also tried to add it like
val show: (target: Element) -> Any = definedExternally
, but it doesn't seem to work too. Any suggestions?
I would appreciate even just a link to some source code which looks like this one. I'm not sure that switching to the old compiler is the thing I want to do, but probably it will work then without such hacks.
t
Untitled.kt
j
@turansky It says two errors then:
Wrong body of external declaration. Must be either ' = definedExternally' or { definedExternally }
and
Inline external declaration
. The second error can be fixed by removing
inline
, but what about the first one?
But I got your point about calling these methods on
default
, thanks!
t
You can add such annotation on file
Copy code
@file:Suppress("INLINE_EXTERNAL_DECLARATION")
🙌 1
Also you can vote here to legalize powerful declarations 🙂
j
@turansky Looks good, thank you a lot! The issue also looks reasonable and just today I wanted to use extension functions, but the compiler didn't let me do it. Voted!
t
All options, described in issue are already supported by compiler :)
All what you need - "magic" suppress