Hey guys, how can I get this to work, I am again g...
# javascript
n
Hey guys, how can I get this to work, I am again getting confused by ReactNode and Elements. I have this attribute on a wrapper ComponentClass
Copy code
var renderCustomHeader: (Date, (Int) -> Unit, (Int) -> Unit,
                         () -> Unit, () -> Unit,
                         Boolean,
                         Boolean) -> ReactNode?
And I use it like so
Copy code
attrs.renderCustomHeader = {
                date,
                changeYear,
                changeMonth,
                decreaseMonth,
                increaseMonth,
                prevMonthButtonDisabled,
                nextMonthButtonDisabled,
            ->
                div {
                     //other stuff
                 }
}
I tried using createElement, but then the
changeYear, changeMonth
aren't usable
Uncaught TypeError: this._$changeMonth is not a function
t
You can use
create
method to solve this problem
n
@turansky what create method exactly? I am trying to find something that will allow me to create a
div
like in your example you create
TextField
but there doesn't seem to be anything like it.
t
Version
pre.280
required and valid import
n
I'm still on 1.5.31, so I'll have to refactor a few stuff first. Thank you!
Are there any 1.5.31 alternatives maybe? As I am not sure if I'd like to upgrade the project quite yet
t
n
@turansky after the update
Copy code
@JsName("MenuIcon")
external val menuIcon: ComponentClass<IconProps>
Gives me
Unresolved reference: ComponentClass
on compile time, all the references are resolved in the IDE Ton of these
Copy code
Unresolved reference: react
t
IR?
Do you use material icons?
n
I am using HeroIcons from Tailwind Labs, wrote my wrapper for them. Yeah using IR @turansky
t
Original name prefered
MenuIcon
in your case
n
What do you mean exactly?
t
In your example you modify original component name
Classic - component name from upper case
n
Oh, that, yeah I'll have to rename my components to uppercase. But other than that, that shouldnt be causing this issue
This is just one part of the unresolved references, code completion works, typings everything works
t
pre.280
?
n
I went from 1.5.30 to 1.5.31 and upped to
Copy code
"0.0.1-pre.280-kotlin-1.6.0"
Adding this in my root buildsrc
Copy code
allprojects {
    repositories {
        google()
        mavenCentral()
        mavenLocal()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
    }

    plugins.apply("com.github.ben-manes.versions")


    tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask> {
        args += "--ignore-scripts"
    }

    configurations.all {
        resolutionStrategy {
            eachDependency {
                if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin-"))
                    useVersion(Versions.kotlin)
            }
        }
    }
}
t
Looks like version downgrade doesn’t work with IR (If it was applied)
n
Oh
That's quite a predicament then, can I somehow stay at 1.5.31
pre.262 (i belive)
and fulfill this kind of signature?
Copy code
renderCustomHeader?(params: ReactDatePickerCustomHeaderProps): React.ReactNode;

In Kotlin

var renderCustomHeader: (Date, (Int) -> Unit, (Int) -> Unit,
                             () -> Unit, () -> Unit,
                             Boolean,
                             Boolean) -> ReactNode?
And something like this
Copy code
attrs.renderCustomHeader = {
                date,
                changeYear,
                changeMonth,
                decreaseMonth,
                increaseMonth,
                prevMonthButtonDisabled,
                nextMonthButtonDisabled,
            ->
                div {
                     //other stuff
                 }
}
t
Update recommended 🙂
n
Unfortunately, it's quite a large project so not all dependencies are compatible with 1.6.0 from the first glance. But I'll see if I can hack it for the time being