Christian Dräger
09/27/2020, 3:53 PMimplementation(npm(name = "react-toastify", version = "6.0.8", generateExternals = true))
to my build gradle. and it actually does but i am wondering how to use the generated externals.
The libraries documentation says <ToastContainer …props /> has to be added to the apps JSX code. in my generated externals i found a useToastContainer
function in the generated externals (see screenshot). no extension function to RBuilder or something that looks like i can just use it straight away
questions:
is there a naming convention that dukat uses to place the public functions of a dependency like prefixing the file that includes the api of a library with ‘use….’ ? if not, where are the public functions of library placed that has a dukat generated kotlin wrapper?
do i need to write an extension function to RBuilder like `fun RBuilder.toastContainer() = useToastContainer()`to use it with kotlin react wrapper?
useToastContainer
wants ToastContainerProps
which is an interface regarding to the generated externals i couldn’t find an implementation of that interface. I would assume an implementation with default values like the original lib has. so im wondering how to use this or do i have to implement it myself (would be extremely unhandy since it has a lot of props) ?
what experiences do you have using libraries that extend react in kotlinjs?Joffrey
09/27/2020, 4:11 PMRBuilder
extensions by hand to make the lib convenient to use in a Kotlin-React context. However I didn’t have to write the props interface implementation (you can use attrs { … }
to just “set” properties), but I did need to set default values by hand in the RBuilder
extensions.
If you want to take a look at some examples, here are some links to the project where I did this:
• the file declaring RBuilder
extensions by hand, using child()
with the component’s class as parameter
• the package where I sort of generated the typescript declaration with Dukat (a while ago), but be aware that I had to fix all of them manually, and I think it deviates quite a lot from what Dukat would generate now
Note that this information might be outdated, as I did this a few months back and it might have changed a lot in the meantime (for instance “generate externals” was experimental at the time).Christian Dräger
09/27/2020, 4:16 PMJoffrey
09/27/2020, 4:19 PMRBuilder
extension stuff is really specific to Kotlin-react, so I don’t think it has its place in Dukat itself, and I don’t believe it will be implemented there. I don’t know what the next versions of Dukat have to offer though, maybe I should just be a bit more patient and see 😄Christian Dräger
09/27/2020, 4:27 PMJoffrey
09/27/2020, 4:29 PMChristian Dräger
09/27/2020, 4:35 PMChristian Dräger
09/27/2020, 4:40 PMChristian Dräger
09/27/2020, 4:45 PMJoffrey
09/27/2020, 4:49 PMChristian Dräger
09/27/2020, 4:52 PM