Joost Klitsie
02/10/2021, 1:50 PMModifier 'external' is not applicable to 'class'
It looks (for example) like this:
external interface EventDetailsContractProps: BaseProps {
var eventId: UUID
var handler: EventDetailsContract.Handler
}
interface EventDetailsContract {
interface Handler: EventSummaryContract.Handler {
fun onEventDetailsFinished()
}
}
data class EventDetailsProps constructor(
override var eventId: UUID,
override var handler: EventDetailsContract.Handler
): EventDetailsContractProps
This code is shared between my javascript and android targets. Is there any way to resolve this? I could try:
expect interface EventDetailsContractProps {
var eventId: UUID
var handler: EventDetailsContract.Handler
}
And then make a platform specific actual
Interface, but that would mean a lot of boilerplate (As I would have to rewrite the interface 3 times).Marc Knaup
02/10/2021, 1:55 PMexternal
in outside of Kotlin/JS. Also not with expect
/ actual
.
You’ll have to wrap your props.
external interface MyProps<T> {
var value: T
}
Then your component has MyProps<EventDetailsContractProps>
as props where EventDetailsContractProps
is a regular class
or interface
.
kotlin-react
is annoying in that regard. For that reason and others I’ve created my own 🙂
https://github.com/fluidsonic/fluid-react
(no class components though and requires IR compiler)Joost Klitsie
02/10/2021, 1:56 PMMarc Knaup
02/10/2021, 1:57 PMvalue is EventDetailsContractProps
or value.equals(…)
etc. won’t work and just crash.Joost Klitsie
02/10/2021, 1:59 PMJoost Klitsie
02/10/2021, 1:59 PMMarc Knaup
02/10/2021, 2:00 PMexternal
. Hence I’ve made my own library 😉